HTTP header and Content-Type

  • mk27
  • Proficient
  • Proficient
  • User avatar
  • Joined: Jun 09, 2009
  • Posts: 334
  • Status: Offline

Post July 7th, 2009, 11:53 am

AFAICT, the last line of an HTTP header is always Content-Type, which means the content begins after the next newline.

However, I was just googling around and I cannot find it stated anywhere by anyone that this *must* be the case, ie, a server could return Content-Type as the first line of the header. That means the above method is not guaranteed to succeed. Does anyone know how you are supposed to determine where a header ends and the content begins?
Image
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 7th, 2009, 11:53 am

  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Joined: Jul 25, 2005
  • Posts: 2735
  • Loc: Nashville, TN
  • Status: Offline

Post July 7th, 2009, 11:57 am

What language are you processing with? I assume you've returned a large blob and now you're trying to parse it. Is this a last-chance move to try and extract the content?
I'd love to change the world, but they won't give me the source code.
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6130
  • Loc: Seattle, WA
  • Status: Offline

Post July 7th, 2009, 12:03 pm

There's nothing in the HTTP spec that states that the Content-Type header must come last in the stream before the content.
The Beer Monocle. Classy.
  • mk27
  • Proficient
  • Proficient
  • User avatar
  • Joined: Jun 09, 2009
  • Posts: 334
  • Status: Offline

Post July 7th, 2009, 12:09 pm

I'm working in C. I've never had a problem just using the Content-Type as the boundary, but now I am required to provide a reliable product for someone else I wanted to make sure this practice (don't remember where I picked it up!) is well, reliable.

Anyway, I think the problem is solved as I found this in RFC 2616, sec 4:

Both types of message consist of a start-line, zero or more header fields (also known as "headers"), an empty line (i.e., a line with nothing preceding the CRLF) indicating the end of the header fields, and possibly a message-body.

Whew! Glad I checked...
Moderator Remark: Linked up RFC reference
Image

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 82 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.