Description of problem:
When using the Glance image data API's Content-Range support to partially download an image, the server sets a Content-Length header equal to the size of the full image, rather than the size of the chunk specified by the requested Content-Range. This causes clients to wait indefinitely for the server.
Version-Release number of selected component (if applicable):
It at least affects Glance 11.0.1
Steps to Reproduce:
1. Make an authenticated GET request to /v2/images/<some_image_id>/file with
the Content-Range header set to some value smaller than the entire length
of the image.
Server returns a Content-Length header equal to the length of the whole image but only transmitting the requested bytes. The client waits indefinitely for the server to continue sending.
Server returns a Content-Length header equal to the number of bytes in the chunk, so that the client can know to disconnect.
If you manually specify the Connection: close header rather than using the default Connection: keep-alive, the server terminates the connection after sending the right amount of bytes, although it still sends the wrong Content-Length header.
By the looks of it, the error happens here  when the range is specified.
According to the Content-Range RFC, the Content-Length should be equal to the number of bytes transmitted, in this case it'd be the size of the chunk: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Can this please be reported upstream and fixed there?
I agree, must be filled upstream, but we should also have a way to track it here so please after you open the bug, add here the bug id on the external bug tracker.
If not given the range in the correct form, should not just return 412 Precondition Failed and exit?
I've reported a bug upstream and added the bug ID here.
I'm on it :)
Out of curiosity, is it possible to somehow tell through the API whether or not the version of Glance v2 contains the fix or not? We're trying to figure out the best way to have our code support both OpenStacks with and without the fix.
No recent progress on this issue. Moving to RHOS 11 for triage.
The fix seems to be in stable/ocata upstream, and in our downstream packages as well, so let's push this to QA.
RPM : openstack-glance-14.0.0-2.el7ost.noarch
image was successfully downloaded
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.