I'm creating an API in which it is possible to upload a file in a chunked manner.
我正在创建一个API,可以在其中以分块方式上传文件。
Going by this * question and answer, the content-range header seems most appropriate for this.
通过此*问题和答案,内容范围标题似乎最适合此。
However, in the controller action the header has been stripped so I can't access it. When I use the 'range' header it is available in the request headers collection.
但是,在控制器操作中,标头已被剥离,因此我无法访问它。当我使用'range'标头时,它在请求标头集合中可用。
Anyone an idea why the Content-Range is stripped from Requests?
任何人都知道为什么内容范围被从请求中删除?
1 个解决方案
#1
8
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.
它没有被剥离。在Request.Content.Headers中查找它。看起来他们将标头与HTTP / 1.1规范对齐 - 将实体标头移动到Request.Content.Headers。我在样本请求中尝试了它并在那里找到了它。
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.
我在阅读RFC 2616的相关章节后发现了这一变化。我最近一直在讨论它,因为主要作者Fielding也是REST架构风格的发明者,我试图使用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:
看起来好像ASP.NET团队修改了类模型以更好地镜像RFC,创建了HttpHeaders的三个子类:
- HttpRequestHeaders for "5.3 Request Header Fields" and "4.5 General Header Fields"
- HttpRequestHeaders为“5.3请求标题字段”和“4.5通用标题字段”
- HttpResponsHeaders for "6.2 Response Header Fields" and "4.5 General Header Fields"
- HttpResponsHeaders为“6.2响应标题字段”和“4.5通用标题字段”
- HttpContentHeaders for "7.1 Entity Header Fields"
- “7.1实体标题字段”的HttpContentHeaders
These are the verbatim descriptions of the three classes in MSDN (the links are mine):
这些是MSDN中三个类的逐字描述(链接是我的):
- HttpRequestHeaders: Represents the collection of Request Headers as defined in RFC 2616.
- HttpRequestHeaders:表示RFC 2616中定义的请求标头集合。
- HttpResponseHeaders: Represents the collection of Response Headers as defined in RFC 2616.
- HttpResponseHeaders:表示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.
- HttpContentHeaders:表示RFC 2616中定义的内容标头集合.Content-Range是实体标头,因此ContentRange位于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.
请注意,虽然MSDN类描述有点误 - RFC中没有内容标题定义,但很明显它们是实体标题。
#1
8
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.
它没有被剥离。在Request.Content.Headers中查找它。看起来他们将标头与HTTP / 1.1规范对齐 - 将实体标头移动到Request.Content.Headers。我在样本请求中尝试了它并在那里找到了它。
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.
我在阅读RFC 2616的相关章节后发现了这一变化。我最近一直在讨论它,因为主要作者Fielding也是REST架构风格的发明者,我试图使用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:
看起来好像ASP.NET团队修改了类模型以更好地镜像RFC,创建了HttpHeaders的三个子类:
- HttpRequestHeaders for "5.3 Request Header Fields" and "4.5 General Header Fields"
- HttpRequestHeaders为“5.3请求标题字段”和“4.5通用标题字段”
- HttpResponsHeaders for "6.2 Response Header Fields" and "4.5 General Header Fields"
- HttpResponsHeaders为“6.2响应标题字段”和“4.5通用标题字段”
- HttpContentHeaders for "7.1 Entity Header Fields"
- “7.1实体标题字段”的HttpContentHeaders
These are the verbatim descriptions of the three classes in MSDN (the links are mine):
这些是MSDN中三个类的逐字描述(链接是我的):
- HttpRequestHeaders: Represents the collection of Request Headers as defined in RFC 2616.
- HttpRequestHeaders:表示RFC 2616中定义的请求标头集合。
- HttpResponseHeaders: Represents the collection of Response Headers as defined in RFC 2616.
- HttpResponseHeaders:表示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.
- HttpContentHeaders:表示RFC 2616中定义的内容标头集合.Content-Range是实体标头,因此ContentRange位于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.
请注意,虽然MSDN类描述有点误 - RFC中没有内容标题定义,但很明显它们是实体标题。