POST with empty body results in 411 Error

Bug #1238536 reported by Phil Day
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Invalid
Undecided
Unassigned
tempest
Invalid
Undecided
Andrea Frittoli

Bug Description

Some API commands don't need a body - for example allocating a floating IP. However making a request without a body results in a 411 error:

curl -i https://compute.systestb.hpcloud.net/v2/21240759398822/os-floating-ips -H "Content-Type: application/xml" -H "Accept: application/xml" -H "X-Auth-Token: xxx" -X POST
HTTP/1.1 411 Length Required
nnCoection: close
Content-Length: 284

Fault Name: HttpRequestReceiveError
Error Type: Default
Description: Http request received failed
Root Cause Code: -19013
Root Cause : HTTP Transport: Couldn't determine the content length
Binding State: CLIENT_CONNECTION_ESTABLISHED
Service: null
Endpoint: null

Passing an Empty body works:
curl -i https://compute.systestb.hpcloud.net/v2/21240759398822/os-floating-ips -H "Content-Type: application/xml" -H "Accept: application/xml" -H "X-Auth-Token: xxx" -X POST -d ''
HTTP/1.1 200 OK
Content-Length: 164
Content-Type: application/xml; charset=UTF-8
Date: Fri, 31 May 2013 11:13:26 GMT
X-Compute-Request-Id: req-cc2ce740-6114-4820-8717-113ea1796142

<?xml version='1.0' encoding='UTF-8'?>
<floating_ip instance_id="None" ip="15.184.42.154" fixed_ip="None" id="3f9ce21c-d192-4478-8dd1-f7eb68d70133" pool="Ext-Net"/>

Tags: api
GuoHui Liu (guohliu)
tags: added: api
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

Phil,

seems to work for me.

dims@dims-desktop:~/devstack$ curl -vs -i http://127.0.0.1:8774/v2/068bbe5294a44591aa138d0de5fe8f42/os-floating-ips -H "Content-Type: application/xml" -H "Accept: application/xml" -H "X-Auth-Token: 357bc34f43f140c2b5f4f0b373712e17" -X POST
* About to connect() to 127.0.0.1 port 8774 (#0)
* Trying 127.0.0.1...
* connected
* Connected to 127.0.0.1 (127.0.0.1) port 8774 (#0)
> POST /v2/068bbe5294a44591aa138d0de5fe8f42/os-floating-ips HTTP/1.1
> User-Agent: curl/7.27.0
> Host: 127.0.0.1:8774
> Content-Type: application/xml
> Accept: application/xml
> X-Auth-Token: 357bc34f43f140c2b5f4f0b373712e17
>
* additional stuff not fine transfer.c:1037: 0 0
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Content-Type: application/xml
Content-Type: application/xml
< Content-Length: 127
Content-Length: 127
< X-Compute-Request-Id: req-fae30a8e-f143-4556-90db-cfff970667ec
X-Compute-Request-Id: req-fae30a8e-f143-4556-90db-cfff970667ec
< Date: Fri, 11 Oct 2013 12:07:36 GMT
Date: Fri, 11 Oct 2013 12:07:36 GMT

<
<?xml version='1.0' encoding='UTF-8'?>
* Connection #0 to host 127.0.0.1 left intact
<floating_ip instance_id="None" ip="172.24.4.226" fixed_ip="None" id="2" pool="public"/>* Closing connection #0

Changed in nova:
status: New → Incomplete
Revision history for this message
Phil Day (philip-day) wrote :

Looks like the problem is specific to our network

Changed in nova:
status: Incomplete → Invalid
Revision history for this message
Andrea Frittoli (andrea-frittoli) wrote :

httplib2 is not setting content-length to 0 if the post body is empty (https://code.google.com/p/httplib2/issues/detail?id=143).

Certain http servers won't be happy if the content length is not set. Tempest rest client should do that.

Changed in tempest:
assignee: nobody → Andrea Frittoli (andrea-frittoli)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tempest (master)

Fix proposed to branch: master
Review: https://review.openstack.org/69625

Changed in tempest:
status: New → In Progress
Revision history for this message
Sean Dague (sdague) wrote :

Because it looks like HP network specific issue

Changed in tempest:
status: In Progress → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.