Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Work around Google HTTP client giving null content for HEAD requests #116

Closed
coollog opened this issue Jan 17, 2018 · 12 comments
Closed

Work around Google HTTP client giving null content for HEAD requests #116

coollog opened this issue Jan 17, 2018 · 12 comments
Projects

Comments

@coollog
Copy link
Contributor

coollog commented Jan 17, 2018

The Google HTTP client gives null content for HEAD requests. Docker registry can return useful content for HEAD responses. In BlobChecker, this content can contain useful registry error codes to parse.

@coollog coollog added this to To Do in Crepecake via automation Jan 17, 2018
@elharo
Copy link

elharo commented Jan 18, 2018

Do you mean it returns it in the body or the headers? The body should be null or empty, and if the Google HTTP client is returning null headers that's a bug we need to report upstream.

@coollog
Copy link
Contributor Author

coollog commented Jan 18, 2018

The Google HTTP client intentionally wipes empty the body for the response of any HEAD request. This follows the RFC specs for HEAD requests, but the Docker registry can send content bodies back as responses to HEAD requests.

@elharo
Copy link

elharo commented Jan 18, 2018

I suspect Docker is violating the HTTP spec. We probably shouldn't depend on that.

@elharo
Copy link

elharo commented Jan 18, 2018

This would be a violation of HTTP. Per the HTTP 1.1 spec:

"The HEAD method is identical to GET except that the server MUST NOT
send a message body in the response (i.e., the response terminates at
the end of the header section). "

@coollog
Copy link
Contributor Author

coollog commented Jan 18, 2018

Yeah, it is. This issue might not be something we can fix. Also, the only benefit of fixing this issue would be more fine-grained error messages. We can just keep it as is and assume any HTTP Not Found error when performing the BLOB-check HEAD request means the BLOB doesn't exist.

@elharo
Copy link

elharo commented Jan 18, 2018

If they are really doing this, we need to file a bug against them. That's very broken.

A 404 should be fully sufficient to demonstrate non-existence.

@coollog
Copy link
Contributor Author

coollog commented Jan 18, 2018

The 404 response for a BLOB check can contain other error codes in the response body besides BLOB_UNKNOWN. For example, if the repository in which the BLOB check was done does not exist in the first place, the error code would be NAME_UNKNOWN. In any case, the BLOB does not exist, but the body just gives more details into the reason for its non-existence.

@elharo
Copy link

elharo commented Jan 18, 2018

If that's what you want you need a GET, not a HEAD.

Seriously, I cannot emphasize how broken this is. The Google HTTP client library is hardly the only thing out there on the Internet that is going strip bodies from HEAD responses.

If Docker is doing this we need to file a bug against them.

@loosebazooka
Copy link
Member

You can't do a HEAD then a GET to get the reason?

@elharo
Copy link

elharo commented Jan 18, 2018

Yes, you can do that. Just don't ever expect to see a body in a HEAD response.

@coollog
Copy link
Contributor Author

coollog commented Jan 18, 2018

@loosebazooka Yep, that sounds like a reasonable way to get around this issue.

@coollog
Copy link
Contributor Author

coollog commented Jan 29, 2018

Moved to GoogleContainerTools/jib#21

@coollog coollog closed this as completed Jan 29, 2018
Crepecake automation moved this from To Do to Done Jan 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Crepecake
  
Done
Development

No branches or pull requests

3 participants