Is using the HTTP Content-Range header appropriate when sending a file in chunks using the POST method?

自闭症网瘾萝莉.ら 提交于 2019-12-09 01:41:25

问题


I am working on an existing Silverlight file uploader that breaks files into multiple chunks and transmits the file using multiple HTTP requests.

Currently, it sends the start and total byte information on the querystring, but as learning exercise, I'd like to use a more standards-based approach.

I've previously used the HTTP Content-Range header when implementing an endpoint that serves content. Is this header also appropriate to use when posting content from a client to the server?


回答1:


Yes.

RFC 2616 (HTTP 1.1), Section 14 begins by stating:

For entity-header fields, both sender and recipient refer to either the client or the server, depending on who sends and who receives the entity.

Other than that, Section 14.16, which defines the Content-Range header, does not appear to contain any language limiting its use to either the request or response.




回答2:


Probably not, at least as of 2014 (the original answer is from 2011).

The updated HTTP 1.1 specification, rfc7231 (4.3.3), says the following about valid POST responses:

An origin server indicates response semantics by choosing an appropriate status code depending on the result of processing the POST request; almost all of the status codes defined by this specification might be received in a response to POST (the exceptions being 206 (Partial Content), 304 (Not Modified), and 416 (Range Not Satisfiable)).

Given that this language was explicitly added to the updated spec, I doubt the authors intended that the Content-Range header be used with the POST method.



来源:https://stackoverflow.com/questions/7464176/is-using-the-http-content-range-header-appropriate-when-sending-a-file-in-chunks

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