Bug #897
closedRGW does not send content-length for HEAD requests sometimes
0%
Description
RGW does not send content-length for HEAD requests when content-length would be 0. This breaks libboto:
cmccabe@metropolis:~/src/ceph/src/osync$ ./osync.py -v file:///tmp/a s3://rgw-1.ceph.dreamhost.com/test-bucket/ obj.name = a2 Traceback (most recent call last): File "./osync.py", line 324, in <module> dobj = dst.locate_object(sobj) File "./osync.py", line 172, in locate_object k = self.bucket.get_key(obj.name) File "/usr/lib/pymodules/python2.6/boto/s3/bucket.py", line 130, in get_key k.size = int(response.getheader('content-length')) TypeError: int() argument must be a string or a number, not 'NoneType'
Examination with wireshark reveals that the content-length header is missing on RGW's response.
We can patch libboto, of course, but I suspect that this kind of behavior will break a lot of other ad-hoc clients that people have written over the years.
Apparently not sending content-length when it is 0 is considered a feature by the apache guys and is not going away:
http://marc.theaimsgroup.com/?l=apache-modperl&m=108647669726915&w=2
http://marc.theaimsgroup.com/?t=109122984600001&r=1&w=2
There are some hints that there may be a workaround for CGI clients.
From http://perl.apache.org/docs/2.0/user/handlers/http.html#C_Content_Length__Response_Header
> Not getting Content-Length header with HEAD requests > Even though the spec says that content handlers should send an identical > response for GET and HEAD requests, some folks try to avoid the overhead > of generating the response body, which Apache is going to discard anyway > for HEAD requests. The following discussion assumes that we deal with a > HEAD request. > > When Apache sees EOS and no headers and no response body were sent, > ap_content_length_filter() (httpd-2.0/server/protocol.c) sets C-L to 0. > Later on ap_http_header_filter() (httpd-2.0/modules/http/http_protocol.c) > removes the C-L header for the HEAD requests. > > The workaround is to force the sending of the response headers, before EOS > was sent (which happens when the response handler returns). The simplest > solution is to use rflush():
Files