You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
blob_writer.go does not handle Range header properly #1240
However, blob_writer.go does not handle the "bytes=" part of the Range-header, but assumes the header only contain <int>-<int>
rng := resp.Header.Get("Range")
var start, end int64
if n, err := fmt.Sscanf(rng, "%d-%d", &start, &end); err != nil {
return 0, err
} else if n != 2 || end < start {
return 0, fmt.Errorf("bad range format: %s", rng)
}
Similarily, docker registry most likely does not include a "bytes=" prefix in it's Reange header response either..
RFC2616 section 14.35.1 Byte Ranges specifies bytes= as required.
My GO skills are limited, so cannot provide patch, but not sure this should be patched, as it might be intentional behaviour (the documentation does state the API uses the Range header in a non-standard way) ?
It sounds like you're expecting this header to be present on the initial request. This isn't really necessary, since the initial size of a new upload should always be zero. Please read the specification carefully, as it covers this, in detail. From that point, the registry will populate the Range header on get to the upload location (this is filled in here) or after each chunk post (which isn't implemented).
We also use the Range syntax as part of requests to communicate the chunking of an upload in the registry. This is non-standard, in that the client sets the Content-Range header and issues PUT requests. We haven't had needed to implement this (Chunking), as it turns out to be less than useful, until other optimization have been implemented.
If you want to use Range requests on get, they are already full supported.
My suggestion would be to read over the specification more carefully and dump the flow of the client. If you are accessing Range headers, you're likely not implementing the protocol correctly.
@stevvooe Appreciate the response, but the "issue" was not really about if the Range header is there at any given time or not, but about how it's value is being formatted/interpreted. The spec (Registry HTTP API V2, aswell as the RFC) states that it should include a "bytes=" prefix, but it does not in Docker's case.
However, as the documentation for the Registry HTTP API V2 also states that the Range header is used in a non-standard fashion, I'm inclined to believe that this is simply a documentation issue, as the code works just fine using the official repository image.
@allbinmani Ah, I see. While this is a non-standard use of Range, the field should match the request header, even if it is on a request. Looks like we are using it here, so no going back.
We'll have to make the client accept both. May need to modify the specification to clarify that parsing the Range header should allow for missing "bytes=", which is mostly redundant anyways.
Activity
stevvooe commentedon Dec 8, 2015
It sounds like you're expecting this header to be present on the initial request. This isn't really necessary, since the initial size of a new upload should always be zero. Please read the specification carefully, as it covers this, in detail. From that point, the registry will populate the
Rangeheader on get to the upload location (this is filled in here) or after each chunk post (which isn't implemented).We also use the
Rangesyntax as part of requests to communicate the chunking of an upload in the registry. This is non-standard, in that the client sets theContent-Rangeheader and issues PUT requests. We haven't had needed to implement this (Chunking), as it turns out to be less than useful, until other optimization have been implemented.If you want to use
Rangerequests on get, they are already full supported.My suggestion would be to read over the specification more carefully and dump the flow of the client. If you are accessing
Rangeheaders, you're likely not implementing the protocol correctly.allbinmani commentedon Dec 8, 2015
@stevvooe Appreciate the response, but the "issue" was not really about if the Range header is there at any given time or not, but about how it's value is being formatted/interpreted. The spec (Registry HTTP API V2, aswell as the RFC) states that it should include a "bytes=" prefix, but it does not in Docker's case.
However, as the documentation for the Registry HTTP API V2 also states that the Range header is used in a non-standard fashion, I'm inclined to believe that this is simply a documentation issue, as the code works just fine using the official repository image.
stevvooe commentedon Dec 8, 2015
@allbinmani Ah, I see. While this is a non-standard use of
Range, the field should match the request header, even if it is on a request. Looks like we are using it here, so no going back.We'll have to make the client accept both. May need to modify the specification to clarify that parsing the
Rangeheader should allow for missing "bytes=", which is mostly redundant anyways.