Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[http handler] add GET fallback if HEAD is not allowed or forbidden to get key size #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thomascoquet
Copy link
Contributor

  • Adding a fallback to get resource size if HEAD is not allowed.
  • Similar behavior to GDAL vsicurl.
  • Mainly used with URLs that are presigned for only one HTTP verb (AWS, GS).

@coveralls
Copy link

coveralls commented Feb 10, 2022

Pull Request Test Coverage Report for Build 1823560964

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 24 of 36 (66.67%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.8%) to 89.481%

Changes Missing Coverage Covered Lines Changed/Added Lines %
http.go 24 36 66.67%
Files with Coverage Reduction New Missed Lines %
http.go 1 64.29%
Totals Coverage Status
Change from base Build 1667244230: 0.8%
Covered Lines: 689
Relevant Lines: 770

💛 - Coveralls

@tbonfort
Copy link
Member

Couldn't the HEAD request be skipped completely and instead always do a GET request for the first block that populates the cache and sets the size in a single request ?

@thomascoquet
Copy link
Contributor Author

Do you mean parsing the Content-Range header instead of relying on the Content-Length one?

HTTP/1.1 206 Partial Content
Content-Range: bytes 0-1023/146515
Content-Length: 1024

Do you agree it requires modifying func (a *Adapter) Size(key string) (int64, error) ?
I can take a look ; it seems reasonable given we need the first block in most contexts (except in zips).

@tbonfort
Copy link
Member

I'm not sure exactly which headers need to be parsed, your proposed solution seems reasonable. There is no need to modify the Adapter.Size function itself, all changes would happen in HTTPHandler.StreamAt with the parsing of Content-Range happening after having received the GET response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants