DEV Community

Discussion on: Where to Put Response Metadata - Envelope or HTTP Headers?

Collapse
 
ecarrara profile image
Erle Carrara

One issue is that the type of values passed through HTTP headers is always a string.

Collapse
 
elmuerte profile image
Michiel Hendriks

Not really. Content-Length for example is an integer.

Collapse
 
joeflateau profile image
Joe Flateau

It's still a string, a string representation of an integer, but a string none the less.

Thread Thread
 
elmuerte profile image
Michiel Hendriks

So is JSON and XML. It's one big string of characters.

Collapse
 
bgadrian profile image
Adrian B.G.

The body is also a string, of a HTTP request and response.

Collapse
 
ecarrara profile image
Erle Carrara

Yes, body is a raw data that you can serialize to represent values with types (usually according to Content-Type header).

See RFC 723. tools.ietf.org/html/rfc7230#sectio...

Historically, HTTP has allowed field content with text in the ISO-8859-1 charset [ISO-8859-1], supporting other charsets only through use of [RFC2047] encoding. In practice, most HTTP header field values use only a subset of the US-ASCII charset [USASCII]. Newly defined header fields SHOULD limit their field values to US-ASCII octets. A recipient SHOULD treat other octets in field content (obs-text) as opaque data.

The body of http message can be anything you like... But headers not.