From f9176924fede1b947fa6bcc04e2295ca9d995ebc Mon Sep 17 00:00:00 2001 From: loganhz Date: Mon, 10 Dec 2018 16:21:54 +0800 Subject: [PATCH] Fix healthcheck http headers field issue https://github.com/rancher/rancher/issues/16853 --- app/components/form-healthcheck/component.js | 31 ++++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/app/components/form-healthcheck/component.js b/app/components/form-healthcheck/component.js index 5af02573b..b71cea645 100644 --- a/app/components/form-healthcheck/component.js +++ b/app/components/form-healthcheck/component.js @@ -60,15 +60,18 @@ export default Component.extend({ } if ( type === HTTP || type === HTTPS ) { - const originalHeaders = get(check, 'httpHeaders') || {}; + const originalHeaders = get(check, 'httpHeaders') || []; let host = null; const headers = {}; - Object.keys(originalHeaders).forEach((key) => { - if ( key.toLowerCase() === 'host' ) { - host = originalHeaders[key]; + originalHeaders.forEach((h) => { + const name = (get(h, 'name') || ''); + const value = (get(h, 'value') || ''); + + if ( name.toLowerCase() === 'host' ) { + host = value; } else { - headers[key] = originalHeaders[key]; + set(headers, name, value); } }); @@ -114,16 +117,26 @@ export default Component.extend({ if ( get(this, 'isHttpish') ) { const host = get(this, 'host'); - const hostHeader = {}; + const httpHeaders = []; if ( host ) { - hostHeader['Host'] = host; + httpHeaders.push({ + name: 'Host', + value: host + }) } - const headers = Object.assign({}, hostHeader, get(this, 'headers')); + const headers = get(this, 'headers'); + + Object.keys(headers).forEach((header) => { + httpHeaders.push({ + name: header, + value: get(headers, header) + }) + }) setProperties(check, { - httpHeaders: headers, + httpHeaders, path: get(this, 'path') || '/', scheme: get(this, 'isHttps') ? 'HTTPS' : 'HTTP' });