• 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.
  • Posts

    • Save $90 on a Microsoft Office 2024 Home & Business for Mac or PC license by Steven Parker Today's highlighted deal comes via Neowin Deals store, where you can save 36% on Microsoft Office 2024 Home & Business for Mac or PC Lifetime License. (buying link below) The essentials to get it all done. Microsoft Office 2024 Home is the latest version of Microsoft’s renowned productivity suite, which includes essential applications like Word, Excel, PowerPoint, and OneNote. This version is specifically designed for individuals and families seeking reliable tools for various home tasks, including document creation, spreadsheet management, presentation design, and note-taking. Office Home 2024 is for students and families who want classic Office apps on their Mac or PC. A one-time purchase installed on 1 PC or Mac for use at home or school. Lifetime license for MS Word, Excel, PowerPoint, & OneNote One-time purchase installed on 1 Windows PC for use at home or work Instant Delivery & Download – access your software license keys and download links instantly Free customer service – only the best support! Microsoft Office 2024 Home for PC or Mac includes: Microsoft Office Word Microsoft Office Excel Microsoft Office PowerPoint Microsoft Office OneNote No faffing about with subscriptions, just classic apps that don't expire.Good to Know ONE-TIME PURCHASE INSTALLED ON 1 DEVICE Redemption deadline: redeem your code within 30 days of purchase Access options: desktop Full versions No subscriptions – no monthly/annual fees Version: 2024 Updates included A lifetime subscription to Microsoft Office Home 2024 normally costs $249.99, but this deal can be yours for just $159.97, that's a saving of $90. For full terms, specifications, and license info, click the link below. Get Microsoft Office 2024 for just $159.97 (36% off MSRP: $249.99) Although priced in U.S. dollars, this deal is available for digital purchase worldwide. We post these because we earn commission on each sale so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. Other ways to support Neowin Whitelist Neowin by not blocking our ads Create a free member account to see fewer ads Make a donation to support our day to day running costs Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: Neowin benefits from revenue of each sale made through our branded deals site powered by StackCommerce.
    • You may want to reword what you said about compatibility. What you said it correct but being clearer like "Unfortunately, it is not compatible with Xbox or PlayStation consoles.".
    • I am more worried about other drivers on the road not so much the vehicle I am in driving or not. I have little trust in an AI driven car reacting well to a car with a driver doing something random, raging, and/or not following the rules of the road.
  • Recent Achievements

    • Apprentice
      Cole Multipass went up a rank
      Apprentice
    • Posting Machine
      David Uzondu earned a badge
      Posting Machine
    • One Month Later
      Stokenking earned a badge
      One Month Later
    • One Month Later
      Kevin Jones earned a badge
      One Month Later
    • Week One Done
      Kevin Jones earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      548
    2. 2
      ATLien_0
      269
    3. 3
      +Edouard
      194
    4. 4
      +FloatingFatMan
      181
    5. 5
      snowy owl
      137
  • Tell a friend

    Love Neowin? Tell a friend!