Board index » delphi » post vs raw post with TidHTTP

post vs raw post with TidHTTP

I am trying to post some xml from a client to a php script on a server
using a TidHTTP component in Delphi 6.  I'm told that the post needs to
be a "raw post" so that the entire xml document goes to the php xml
parser in one chunk.  I'm simply using the HTTPClient application from
the Indy demos in Delphi 6.  When I post it and look at the debug log I
see that my xml has been broken into lines and I see "Accept: text/html,
*/*" which also looks suspicious.  What do I need to do the change this?

Thanks in advance.

- Asher Atkinson

Here is the debug log:

Connected.
Sent: POST /mypath/myscript.php HTTP/1.0<EOL>
Sent: Host: myhost.com<EOL>
Sent: Accept: text/html, */*<EOL>
Sent: User-Agent: Mozilla/3.0 (compatible; Indy Library)<EOL>
Sent: Content-Length: 263<EOL>
Sent: <EOL>
Sent: <LOGGER_UPLOAD><SAMPLE_DATA><TIME>1034344871</TIME><EOL>
Sent: <DEV>185E7000D8EDC789</DEV><TDELTA>3608</TDELTA><EOL>
Sent: <CH>0</CH><DATA>300.0</DATA><TIME>1034345160</TIME><EOL>
Sent: <DEV>4C0000000C9C8505</DEV><TDELTA>62400</TDELTA><EOL>
Sent: <CH>0</CH><DATA>1.0</DATA></SAMPLE_DATA></LOGGER_UPLOAD><EOL>
Recv: HTTP/1.1 200 OK<EOL>Date: Fri, 11 Oct 2002 20:29:09
GMT<EOL>Server: Apache/1.3.24 (Win32) PHP/4.2.1<EOL>X-Powered-By:
PHP/4.2.1<EOL>Connection: close<EOL>Content-Type:
text/html<EOL><EOL><LOGGER_DOWNLOAD><STATUS>ERROR</STATUS><MSG>ERROR in
XML Parsing: no element found </MSG></LOGGER_DOWNLOAD>
Recv:
Disconnected.
Disconnected.

 

Re:post vs raw post with TidHTTP


I got it to work by setting the content type to text/xml.  I got a tip
from a JAVA guy who said to set content type to anything PHP will not
recognize and it seems to work.  I set it to junk/test and it still
worked.  So though I got my question answered another is raised.  What
is the proper way to set the content type for xml?
Quote
Asher Atkinson wrote:
> I am trying to post some xml from a client to a php script on a server
> using a TidHTTP component in Delphi 6.  I'm told that the post needs to
> be a "raw post" so that the entire xml document goes to the php xml
> parser in one chunk.  I'm simply using the HTTPClient application from
> the Indy demos in Delphi 6.  When I post it and look at the debug log I
> see that my xml has been broken into lines and I see "Accept: text/html,
> */*" which also looks suspicious.  What do I need to do the change this?

> Thanks in advance.

> - Asher Atkinson

> Here is the debug log:

> Connected.
> Sent: POST /mypath/myscript.php HTTP/1.0<EOL>
> Sent: Host: myhost.com<EOL>
> Sent: Accept: text/html, */*<EOL>
> Sent: User-Agent: Mozilla/3.0 (compatible; Indy Library)<EOL>
> Sent: Content-Length: 263<EOL>
> Sent: <EOL>
> Sent: <LOGGER_UPLOAD><SAMPLE_DATA><TIME>1034344871</TIME><EOL>
> Sent: <DEV>185E7000D8EDC789</DEV><TDELTA>3608</TDELTA><EOL>
> Sent: <CH>0</CH><DATA>300.0</DATA><TIME>1034345160</TIME><EOL>
> Sent: <DEV>4C0000000C9C8505</DEV><TDELTA>62400</TDELTA><EOL>
> Sent: <CH>0</CH><DATA>1.0</DATA></SAMPLE_DATA></LOGGER_UPLOAD><EOL>
> Recv: HTTP/1.1 200 OK<EOL>Date: Fri, 11 Oct 2002 20:29:09
> GMT<EOL>Server: Apache/1.3.24 (Win32) PHP/4.2.1<EOL>X-Powered-By:
> PHP/4.2.1<EOL>Connection: close<EOL>Content-Type:
> text/html<EOL><EOL><LOGGER_DOWNLOAD><STATUS>ERROR</STATUS><MSG>ERROR in
> XML Parsing: no element found </MSG></LOGGER_DOWNLOAD>
> Recv:
> Disconnected.
> Disconnected.

Other Threads