HTTP header and Content-Type

  • mk27
  • Proficient
  • Proficient
  • User avatar
  • Posts: 334

Post 3+ Months Ago

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?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Posts: 2733
  • Loc: Nashville, TN

Post 3+ Months Ago

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?
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6252
  • Loc: Seattle, WA

Post 3+ Months Ago

There's nothing in the HTTP spec that states that the Content-Type header must come last in the stream before the content.
  • mk27
  • Proficient
  • Proficient
  • User avatar
  • Posts: 334

Post 3+ Months Ago

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

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 109 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
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.