[http] use Docker-Content-Digest header instead of ETag

Signed-off-by: Jakob Ackermann <das7pad@outlook.com>
This commit is contained in:
Jakob Ackermann 2019-09-20 00:07:43 +02:00
parent 04f4c204d8
commit a2e81ac12c
No known key found for this signature in database
GPG key ID: 17FA08AA7E62A231
4 changed files with 6 additions and 8 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -23,12 +23,10 @@ function Http() {
}
Http.prototype.getContentDigest = function(cb) {
const headers = this.oReq.getAllResponseHeaders();
const start = headers.indexOf('etag: "sha256:');
if (start !== -1) {
if (this.oReq.hasHeader('Docker-Content-Digest')) {
// Same origin or advanced CORS headers set:
// 'Access-Control-Expose-Headers: ETag'
cb(headers.slice(start + 7, headers.indexOf('"', start + 7)))
// 'Access-Control-Expose-Headers: Docker-Content-Digest'
cb(this.oReq.getResponseHeader('Docker-Content-Digest'))
} else if (window.crypto && window.TextEncoder) {
crypto.subtle.digest(
'SHA-256',

View file

@ -39,7 +39,7 @@
if (!self.dockerCmd) {
registryUI.errorSnackbar(
'Your browser has no SHA256 support. As a workaround your registry ' +
' can set the header `Access-Control-Expose-Headers: ETag`.'
' can set the header `Access-Control-Expose-Headers: Docker-Content-Digest`.'
);
return;
}