Why is the content-range header stripped from requests in ASP.NET Web API?

前端 未结 1 1353
谎友^
谎友^ 2021-02-19 16:24

I\'m creating an API in which it is possible to upload a file in a chunked manner.

Going by this Stackoverflow question and answer, the content-range header seems most a

1条回答
  •  无人及你
    2021-02-19 16:57

    It is not stripped off. Look for it in Request.Content.Headers. It looks like they aligned the headers with the HTTP/1.1 specifications--moving Entity Headers to Request.Content.Headers.
    I tried it in a sample request and found it there.

    I found this change after reading the relevant sections of RFC 2616. I've been going over it lately because the chief author, Fielding, is also the inventor of the REST architectural style, and I am trying to follow that style using ASP.NET Web API.

    I realized that there was a distinction between "request", "response", "general" (used on both request and response but not entity related) and "entity" headers.

    Looks as if the ASP.NET team revised the class model to better mirror the RFC, creating three subclasses of HttpHeaders:

    • HttpRequestHeaders for "5.3 Request Header Fields" and "4.5 General Header Fields"
    • HttpResponsHeaders for "6.2 Response Header Fields" and "4.5 General Header Fields"
    • HttpContentHeaders for "7.1 Entity Header Fields"

    These are the verbatim descriptions of the three classes in MSDN (the links are mine):

    • HttpRequestHeaders: Represents the collection of Request Headers as defined in RFC 2616.
    • HttpResponseHeaders: Represents the collection of Response Headers as defined in RFC 2616.
    • HttpContentHeaders: Represents the collection of Content Headers as defined in RFC 2616. Content-Range is an Entity Header, so ContentRange is in HttpContentHeaders.

    Note, though that MSDN class description is a bit mistaken - there is no Content Headers definition in the RFC, but it is clear they meant Entity Headers.

    0 讨论(0)
提交回复
热议问题