W3C home > Mailing lists > Public > www-talk@w3.org > March to April 2001

Help needed with constructing a HTTP message !!

From: <nl89071@nl.ibm.com>
Date: Thu, 29 Mar 2001 04:38:45 -0500 (EST)
To: www-talk@w3.org
Message-ID: <80256A1E.00354D7D.00@d06mta01.portsmouth.uk.ibm.com>

Hi www-talk,

I am currently working on an application (in C++) which needs to send one
HTTP message to a HTTP server (apache)
The message I am sending is a POST which uploads a file to the server.
Because I only need to send this one message I donīt want to use any HTTP
classes for it, I just want to sent the HTTP message over a plain socket.

Currently I am sending the message as follows :

I open a socket to the server.
I read the file which has to be sent.
I (want to) construct the HTTP message
send it to the server.

I have used a port sniffer to find out how IE or Netscape sends it POST
message to an apache server.
Below is a captureprint of a file sent to Apache.

When I telnet into the Apache server over its HTTP port, I cant get the
server to reply with the "file is sent OK" message, it always sends "upload
I copied and pasted the capture below into my telnet window. When I send a
text file this way it goes fine, the server replies with "file is sent OK",
but when I try to send binary files nothing works, the server keeps
replying with "upload failed".

I really would like some help on this.

The things I would like to know are the following:

- How do I exactly determine the content-length (The RFC2616 is very
confusing) of my HTTP message. ( I mean which lines are part of the header
and which are not)
- How are binary files put into the HTTP message. (My sniffer returns them
as ASCII chars !?)
- How are the end-of-lines implemented. (When I use \r\n as end-of-line
marker the server also replies with failed, aswell as text as binary
files). When I dont paste the \r\n into the telnet when i am posting a text
file it uploads fine.

With kind regards,

Thijs Volders.

This is the capture done when IE sends a binary file to the server.
everything goes fine.
The "c:" is the reaction from the client, "s:" it the reply from the
When I copy/paste this in the telnet window it is not sent correctly!.

Connection trace between (client) and (server)
port 80
Trace start at Wed Mar 28 16:35:32 GMT+02:00 2001

c:POST HTTP/1.0\r\n
c:Accept: application/vnd.ms-powerpoint, application/vnd.ms-excel, applic
c:ation/msword, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*\r
c:Accept-Language: nl\r\n
c:Content-Type: multipart/form-data; boundary=---------------------------
c:Accept-Encoding: gzip, deflate\r\n
c:User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)\r\n
c:Content-Length: 343\r\n
c:Proxy-Connection: Keep-Alive\r\n
c:Pragma: no-cache\r\n\r\n
c:Content-Disposition: form-data; name="MAX_FILE_SIZE"\r\n\r\n
c:Content-Disposition: form-data; name="userfile"; filename="C:\\tmp\\N.t
c:Content-Type: application/x-gzip-compressed\r\n\r\n\1F\8B\b\b\1E

s:HTTP/1.1 200 OK\r\n
s:Date: Wed, 28 Mar 2001 14:35:03 GMT\r\n
s:Server: Apache/1.3.19 (Unix) PHP/4.0.4pl1 mod_ssl/2.8.1 OpenSSL/0.9.6\r
s:X-Powered-By: PHP/4.0.4pl1\r\n
s:Connection: close\r\n
s:Content-Type: text/html\r\n\r\n
s:File transmission initiated from on port 1290.<BR>File re
s:ceived by the server, and stored at /tmp/N.txt.gz<BR>Ok<BR>\r\n
Received on Wednesday, 4 April 2001 14:53:12 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 27 October 2010 18:14:25 GMT