Board index » delphi » INDY HTTP posting?

INDY HTTP posting?

Hey all,

Does anyone have any links that could help me? I need to post the results of
a form like you would do on a website, but I need to do it programmatically.
I also need to retrieve the page that the website would redirect me to. I
only have Delphi 5 Standard Edition so I don't have the TWebbrowser
component... I'll have to use INDY.

Thank you very much if you can be of assistance,

Nick

 

Re:INDY HTTP posting?


Quote
Nicholas Sherlock wrote in message ...
>Hey all,

>Does anyone have any links that could help me? I need to post the results
of
>a form like you would do on a website, but I need to do it
programmatically.
>I also need to retrieve the page that the website would redirect me to. I
>only have Delphi 5 Standard Edition so I don't have the TWebbrowser
>component... I'll have to use INDY.

Posting an HTML form is surprisingly easy. Where
a normal request looks like

GET /index.html HTTP/1.0
<headers, no body>

a form post may look like

GET /action.html?name0=value0&name1=value1&name2=value2...&nameN=valueN
HTTP/1.0
<headers, no body>

or

POST /action.html HTTP/1.0
<headers>
             <--- blank line
name0=value0 <-+- this is the body
name1=value1   |
name2=value2   |
 .             |
 .             |
 .             |
nameN=valueN <-+
             <--- close connection or run out of Content-Length (by header)

Since both are HTTP requests, you'd be getting the
response page if you wanted to or not.

HTTP 1.0 is described in some RFC; ISTR that I tend to
get the number wrong so you'll have to find that out by
yourself if you want to read it. There are also HTTP
versions 0.9 and 1.1, but between ease of use and
functionality, 1.0 is usually the best choice.

The Indy HTTP component will have Get and Post methods
that do this for you, or you could open a TCP connection
and do all the work yourself.

Groetjes,
Maarten Wiltink

Re:INDY HTTP posting?


Thank you very much for your reply! I didn't realise it was so easy to do
:).

Thanks,

Nick

Other Threads