The only case where a PUT request does not require a Content-Length header is for a chunked transfer of an object.
In that case, a client application must specify a header Transfer-Encoding: chunked in the request and the web server will pass the request through.
When creating a container with Openstack.net, a PUT request is sent with the following headers:
Content-Type: application/json
Accept: application/json
User-Agent: openstack.net/1.3.0.0
X-Auth-Token: [deleted]
Host: [Swift endpoint]
Since no Content-Length headers are set, this is a problem when the object storage endpoint is located behind load balancers or web servers that are standards-compliant (examples that come to mind: Apache, Nginx).
The header is provided in the examples provided by the documentation quoted in the comments in the code.
See:
This is also the behavior of the official Swift client library - python-swiftclient:
curl -i http://[Swift endpoint]/v1/AUTH_[...]/container -X PUT -H "Content-Length: 0" -H "X-Auth-Token: [token]"
swift-proxy does not enforce this header strictly for the creation of containers - it is something that it should do but cannot be done without breaking backwards compatibility and that is why it still behaves this way.
The only case where a PUT request does not require a
Content-Lengthheader is for a chunked transfer of an object.In that case, a client application must specify a header
Transfer-Encoding: chunkedin the request and the web server will pass the request through.When creating a container with Openstack.net, a PUT request is sent with the following headers:
Since no
Content-Lengthheaders are set, this is a problem when the object storage endpoint is located behind load balancers or web servers that are standards-compliant (examples that come to mind: Apache, Nginx).The header is provided in the examples provided by the documentation quoted in the comments in the code.
See:
This is also the behavior of the official Swift client library -
python-swiftclient:swift-proxy does not enforce this header strictly for the creation of containers - it is something that it should do but cannot be done without breaking backwards compatibility and that is why it still behaves this way.