Skip to content
  • Aaron Lehmann's avatar
    Avoid stat round-trips when fetching a blob · 6beeb935
    Aaron Lehmann authored
    
    
    Without this commit, three round-trips are required to fetch a blob with
    a progress bar. The first is a call to Stat (HEAD request), to determine
    the size. Then Open is called, which also calls Stat, and finally
    performs a GET request.
    
    Only the GET request is actually needed. The size of the blob can be
    sniffed from Content-Length in the GET response.
    
    This commit changes HTTPReadSeeker to automatically detect the size from
    Content-Length instead of requiring it to be passed in. The Stat call is
    removed from Open because it is no longer necessary.
    
    HTTPReadSeeker now takes an additional errorHandler callback argument which
    translates an unsuccessful HTTP response into an appropriate API-level
    error. Using a callback for this makes it possible to avoid leaking the
    repsonse body to Read's caller, which would make lifecycle management
    problematic.
    
    Fixes #1223
    
    Signed-off-by: default avatarAaron Lehmann <aaron.lehmann@docker.com>
    6beeb935
Loading