• 0

Obtaining Content-Length in HTTP 1.1 Requests


Question

Hi

I'm having problems retrieving the Content-Length header from HTTP requests used by an application i'm writing. It seems some servers wanna send filesizes, and some don't.

Is there any optional arguments or something I can use in a request to force the server to send a Content-Length header.

Requests are in HTTP 1.1, using Apache under Windows XP if that helps.

I've tried explaining as easily as I can, sorry if it sounds confusing ;)

5 answers to this question

Recommended Posts

  • 0

Thanks for the replies.. really appreciated. So how do I disable chunked encoding? Most servers send 'Transfer-Encoding: chunked' in their responses without me specififing whether I want it or not.

Here's a sample of the type of request i'm sending.

GET /image.gif HTTP/1.1
HOST: www.sitenamehere.com
Connection: close

Unfortunately I don't know much about this so if someone can help me it would be greatly appreciated.

  • 0

Oh! I assumed the server was under your control. Apperently Not.

If you want to stay with HTTP/1.1 then you will have to use the HEAD verb.

HEAD /images/logo.gif HTTP/1.1
HOST: hp.msn.com
Connection: close

The server will respond with the Content-Length header.

If you use HTTP/1.0 then you will get Content-Length instead of Transfer-Encoding.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.