Space Monkey
Space Monkey

Reputation: 143

What's the difference between a content header and a header?

HttpRequestMessage

Has Content.Headers and Headers

Why is that? when I google Http protocol online, I don't see anyone mentioning a content header and a normal header, there are only "headers"

Upvotes: 14

Views: 3795

Answers (2)

Christoph
Christoph

Reputation: 2317

From what I can tell, content headers come into play when you are dealing with MultipartContent or MultipartFormDataContent. The example in this blog post explicity applies a "Content-Type" header at the content level.

http://dotnetcodr.com/2013/01/10/how-to-post-a-multipart-http-message-to-a-web-service-in-c-and-handle-it-with-java/

Upvotes: 0

CodeCaster
CodeCaster

Reputation: 151690

Unfortunately, the MSDN documentation for MVC, WebAPI and System.Net.Http are appaling. See HttpContentHeaders.ContentType Property:

Gets or sets {insert text here}.

Well-known content-specific headers are grouped under "content headers". It's just for convenience. There are headers like content-type, content-length, and so on, as seen in HttpContentHeaders Class:

  • Public property Allow Gets {insert text here}.
  • Public property ContentDisposition Gets or sets {insert text here}.
  • Public property ContentEncoding Gets {insert text here}.
  • Public property ContentLanguage Gets {insert text here}.
  • Public property ContentLength Gets or sets {insert text here}.
  • Public property ContentLocation Gets or sets {insert text here}.
  • Public property ContentMD5 Gets or sets {insert text here}.
  • Public property ContentRange Gets or sets {insert text here}.
  • Public property ContentType Gets or sets {insert text here}.
  • Public property Expires Gets or sets {insert text here}.
  • Public property LastModified Gets or sets {insert text here}.

Upvotes: 11

Related Questions