Thread: http requests

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    722

    http requests

    I'm building a proxy.. but I have a small doubt.
    I connect to the remote server, and send the request. Then I start reading from the socket... When do I know that the server sent all the info I asked?? Should I used the Content-length header? or should I wait for the server to close the connection?
    The same when I reading a request of a client.

    plus, what is the Proxy-Connection suposed to mean ?

  2. #2
    return 0;
    Join Date
    Jan 2005
    Location
    Netherlands
    Posts
    89
    Quote Originally Posted by xErath
    When do I know that the server sent all the info I asked?
    You could use the Content-Length header, but this isn't always sent. The server usually sents information this way:

    [HEADERS]

    [hex number: the number of bytes the next chunk of data is]
    [data]
    [hex number: the number of bytes the next chunk of data is]
    [data]
    When the hex number = 0, it means there is no more data to be read...

    for example:
    HTTP/1.1 200 Ok
    Content-Type: text/html

    10
    abcdefghijklmnop
    5
    xxxxx
    0

    Quote Originally Posted by xErath
    plus, what is the Proxy-Connection suposed to mean ?
    Whether or not the proxy should terminate the connection when all data is sent to the client. ("Proxy-Connection: closed" or "Proxy-Connection: Keep-Alive")

  3. #3
    Registered User
    Join Date
    Dec 2004
    Posts
    95
    Most of the above post is incorrect, I suggest both posters read Section 4.4 of the HTTP 1.1 RFC.

  4. #4
    Registered User
    Join Date
    May 2004
    Posts
    114
    I was wondering about this myself, I got a program to work sending a get request but I cant see how to deal with the response without knowing how long it is because the buffer might be long enough.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Persistent HTTP Requests
    By reelbigtim in forum Networking/Device Communication
    Replies: 9
    Last Post: 10-08-2008, 12:06 AM
  2. Timing HTTP GET requests
    By traef06 in forum C Programming
    Replies: 9
    Last Post: 09-08-2008, 09:33 PM
  3. viewing HTTP requests
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 04-09-2007, 06:44 PM
  4. Writing all HTTP requests from a website to a log file
    By goomyman in forum C# Programming
    Replies: 1
    Last Post: 07-29-2005, 09:18 AM