The difference between the two headers of the web API headers. Content Hosts and Answers.

I find WebPPI individual HTTP response headers in different places, one in Response.Headers, the other in Response.Content.Headers. For example, etag is in Response.Headers, and lastModified is in another. What is the reason for this?

+7
asp.net-web-api
source share
1 answer

There are several answers to this question. One of them is how the HTTP specification defines headers.

RFC 2616

Another more practical reason for separating content headers is that it is easier to write code that processes data in HTTP loads and sets related headers, regardless of request / response objects.

Unfortunately, in the later HTTPbis specification, there has been some reorganization of where they think the headers should go, and now LastModified and Allow are considered response fields, not content fields. This means that the headers defined in System.Net.HttpHeaders will no longer conform to the specification, which really sucks. This also means that we were probably stuck with LastModified as the HttpContent header and Etag as the response header.

HTTPbis

  • Content related headings are defined here .
  • Request headers here .
  • Answer headers here .
+6
source share

All Articles