127658bbee
Instead of just returning a generator for the data, return a tuple of (size, generator). This removes the need to call blob_size in get_blob, and leaves it up to the backend to decide how best to actually get that information. As a result: * The swift backend just needs to do a GET, rather than a HEAD then a GET. Either way, you should still get a Content-Length. * Now neither backend has a race wherein a backing blob may get deleted between the call to blob_size and stream_blob; previously, we could erroneously tell the client the blob exists but is empty. While we're refactoring, add constants for (and increase) the chunk-read size, and include Content-Length headers for GET and HEAD responses. Note that there's a bit of nuance to the return-check now: if the generator is None, the blob could not be found; if the size is None, the blob's size could not be determined -- possibly because we got a chunk-encoded response from swift. In practice, though, expect either both to be None, or neither. Change-Id: Ib85cffe17d2d57cc499d863f1b07cfad8ecd401a