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

View file

@ -39,7 +39,7 @@
if (!self.dockerCmd) { if (!self.dockerCmd) {
registryUI.errorSnackbar( registryUI.errorSnackbar(
'Your browser has no SHA256 support. As a workaround your registry ' + '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; return;
} }