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

夙愿已清 提交于 2019-12-04 04:44:18

问题


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"


回答1:


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}.



回答2:


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/



来源:https://stackoverflow.com/questions/30508837/whats-the-difference-between-a-content-header-and-a-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!