Recent

Author Topic: Ararat Synapse http post in delphi  (Read 17917 times)

Woodyka

  • Newbie
  • Posts: 3
Ararat Synapse http post in delphi
« on: May 02, 2011, 02:41:26 pm »
Dears!

I would like to solve the my problem which is the following:

I have an url: http://example.net/x.html - I have to post there a variable=value - and the answer is an jpeg image, depending on the value. I works correctly with wget, but I would like to use the synapse http units, but I tried, and read about it, but I think my knowledge is too little for it.

But I can downloaded it the image without post:
  HTTP := THTTPSend.Create;
  try
    HTTP.HTTPMethod('POST', 'http://example.net/x.html');
    Memo1.Lines.Assign(HTTP.Headers);
    Memo2.Lines.LoadFromStream(HTTP.Document);
    http.Document.SaveToFile('c:\file.jpg');
  finally
    HTTP.Free;
  end;

It works. Please help me about it, how can I solve it with the mentioned post.

ik

  • Jr. Member
  • **
  • Posts: 88
  • ik
    • LINESIP
Re: Ararat Synapse http post in delphi
« Reply #1 on: May 02, 2011, 06:08:51 pm »
What exactly does not work ?
Do you understand that JPEG is a binary format so you can not display it on TMemo properly ?

Woodyka

  • Newbie
  • Posts: 3
Re: Ararat Synapse http post in delphi
« Reply #2 on: May 02, 2011, 06:12:29 pm »
I mean, about how to send (post) a variable (example: sw) and its value (test) to an url, and get the answer jpg into a file.

I think about httpposturl function , but I cant use it correctly.

vvzh

  • Jr. Member
  • **
  • Posts: 58
Re: Ararat Synapse http post in delphi
« Reply #3 on: May 02, 2011, 08:02:36 pm »
I have not used it myself, but according to documentation you can call it the following way:
Code: [Select]
var
  Response: TMemoryStream;
// ...
Response := TMemoryStream.Create;
try
  HttpPostURL('http://example.net/x.html', 'sw=test', Response);
  Response.SaveToFile('c:\file.jpg');
finally
  Response.Free;
end;

Woodyka

  • Newbie
  • Posts: 3
Re: Ararat Synapse http post in delphi
« Reply #4 on: May 03, 2011, 03:11:57 pm »
Cool!

Thank you very much! So simple solution, but it works as well!

Thank you!

 

TinyPortal © 2005-2018