HTTP 1.1 request

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eagerlearner
    New Member
    • Jul 2007
    • 29

    HTTP 1.1 request

    I am using winsock to build a HTTP 1.1 compliant client, when I made the request with the header
    GET / HTTP/1.1[CRLF]
    Host : www.google.com[CRLF][CRLF]

    After this header is send using function send(), and when I want to receive the html from the server using recv(), it takes sometimes to get the response, as it's because the connection is still alive, the server will only response until the connection timeout, hence I get the response. If I used connection close, I will get the response immediately.

    GET / HTTP/1.1[CRLF]
    Connection: close[CRLF]
    Host : www.google.com[CRLF][CRLF]

    So my question is how can I tell the server it's the end of my request without using the Connection: close header field, so that the server will immediately send response without the connection timeout. or what are the conditions that the server will send response besides, connection closed or connection timeout ? Thanks.
  • kky2k
    New Member
    • May 2007
    • 34

    #2
    Originally posted by eagerlearner
    I am using winsock to build a HTTP 1.1 compliant client, when I made the request with the header
    GET / HTTP/1.1[CRLF]
    Host : www.google.com[CRLF][CRLF]

    After this header is send using function send(), and when I want to receive the html from the server using recv(), it takes sometimes to get the response, as it's because the connection is still alive, the server will only response until the connection timeout, hence I get the response. If I used connection close, I will get the response immediately.

    GET / HTTP/1.1[CRLF]
    Connection: close[CRLF]
    Host : www.google.com[CRLF][CRLF]

    So my question is how can I tell the server it's the end of my request without using the Connection: close header field, so that the server will immediately send response without the connection timeout. or what are the conditions that the server will send response besides, connection closed or connection timeout ? Thanks.
    use \r\n thats it...

    so ur request will be something like..

    GET /HTTP/1.1\r\n
    Host:www.google.com\r\n\r\n

    so the double \r\n will make the server to understand its the end of request ...hope it will help u

    Comment

    Working...