Re: linux socket programming and HTTP Protocol Problem




Paul Hulme wrote:

send(clntSocket, "HTTP/1.1 200 OK\n", 16, 0);

You mean \r\n

Why are you claiming HTTP/1.1 compatability? Try HTTP/1.0

send(clntSocket, "Content-type: text/html\n", 25, 0);

Same thing.

send(clntSocket, "Content-length:\n\n", 18, 0); //extra line feed for
http spec
//html code

Why are you sending an *empty* content length header? If you aren't
going to send the length, don't send this header.

And you need \r\n\r\n to separate the headers from the data.

this is just to test the socket connection. The problem is, i try to
use internet explorer or firefox to connect to the server and retrieve
this test page. Both web browsers connect to the server but both fail
to load the page. Internet explorer complains that it cannot find
server. and firefox says that the connection was reset before the page
could be loaded. The thing is though, if i use wget to connect to the

You are waiting for their complete query right? Otherwise, you may be
closing the connection before they've even *sent* their query.

DS

.



Relevant Pages

  • Re: minimal httpd response
    ... RST, abortively closing the connection. ... The responsibilities of an HTTP/1.1 proxy, and of an HTTP/1.1 server ... user agent, without a proxy, first, and then try to deal ... Connection header; with a Content-length header; or with the chunked ...
    (comp.programming)
  • Re: Is yahoo being hijacked?
    ... I get no server response when query ... > Connection: close ...
    (misc.invest.stocks)
  • Re: Is yahoo being hijacked?
    ... I get no server response when query ... > Connection: close ...
    (misc.invest.stocks)
  • Is yahoo being hijacked?
    ... I get no server response when query ... The server returned the following response headers: ... Connection: close ...
    (misc.invest.stocks)
  • Re: Is yahoo being hijacked?
    ... I get no server response when query ... > Connection: close ...
    (misc.invest.stocks)