in reply to webserver -- incomplete content prob

Your client is not an HTTP client. It completely ignores the Content-Length header which tells the length of the response body. That is the mechanism HTTP uses to indicate when the response ends. Instead, it reads the response by lines which fails as you discovered when the response does not end with a LF. The solution is to read the response header by line, parse out the Content-Length, and then read the body by blocks.

Also, your client should not advertise HTTP 1.1 if it does not support it. Real HTTP will assume they can use stuff like chunked encoding and your client won't handle it.

Finally, is there a reason you can't use LWP for the HTTP client? Or HTTP::Daemon for the server? Both of them handle all the nasty details of the HTTP protocol.

  • Comment on Re: webserver -- incomplete content prob

Replies are listed 'Best First'.
Re: Re: webserver -- incomplete content prob
by flor~ (Initiate) on Apr 08, 2004 at 20:21 UTC
    Thanks for the swift reply =) I think I'll try using the read function then, instead of <FILE>.

    My test environment is actually for an HTTP proxy, so I want to have full control over exactly what the server and client send to each other. For example, LWP uses HTTP 1.0, I want to be able to send 1.1 as well. (For the above sample code, I took out the more involved parsing, including chunks and stuff.)