Reputation: 1885
I'm going to be parsing metadata that will have the same format that HTTP headers/messages do.
I was reading RFC 2616 and I'm trying to understand this more clearly.
Is each HTTP header separated by CRLF (\r\n) and then the separator between the headers and the message body CRLFCRLF(\r\n\r\n)? I couldn't find (or maybe I missed it) anything that detailed what the standard was.
Thanks.
Upvotes: 7
Views: 24121
Reputation: 151594
RFC 2616 (which you shouldn't look at anymore, 7230 is its successor) states:
generic-message = start-line *(message-header CRLF) CRLF [ message-body ]
So there's:
Request-Line
or a Status-Line
, both of which end in CRLF.That being said, you don't want to parse HTTP yourself. Use a library for that.
Example
(picture source)
Upvotes: 20
Reputation: 594
at the start of a message there is a request/status line.
other then that:
according to RFC2616, you are absolutely correct,
however, while RFC2616 specifies the headers' format as *(message-header CRLF)
RFC7230 specifies it as *( header-field CRLF )
apart from the name change, it doesn't seem to be any different, the format for the headers is the same.
tldr; yes.
p.s. parsing the headers for an http message is not that hard, took me a few hours, parsing the message body is mildly difficult but honestly, you should try doing it, it's a good challenge.
Upvotes: 0