Compare commits

...

1 Commits

Author SHA1 Message Date
YanJin b09b812e38 proxy host 2022-06-13 22:29:29 +02:00
3 changed files with 14 additions and 10 deletions

View File

@ -69,11 +69,15 @@ export default function createCanonicalRequest(
const signedHeadersList = pSignedHeaders.split(';'); const signedHeadersList = pSignedHeaders.split(';');
signedHeadersList.sort((a: any, b: any) => a.localeCompare(b)); signedHeadersList.sort((a: any, b: any) => a.localeCompare(b));
const signedHeaders = signedHeadersList.join(';'); const signedHeaders = signedHeadersList.join(';');
const isProxyHost = !!pHeaders['proxyhost'];
// canonical headers // canonical headers
const canonicalHeadersList = signedHeadersList.map((signedHeader: any) => { const canonicalHeadersList = signedHeadersList.map((signedHeader: any) => {
if (pHeaders[signedHeader] !== undefined) { if (pHeaders[signedHeader] !== undefined) {
const trimmedHeader = pHeaders[signedHeader] let header = pHeaders[signedHeader];
if (isProxyHost && signedHeader.toLowerCase() === 'host') {
header = pHeaders['proxyhost'];
}
const trimmedHeader = header
.trim().replace(/\s+/g, ' '); .trim().replace(/\s+/g, ' ');
return `${signedHeader}:${trimmedHeader}\n`; return `${signedHeader}:${trimmedHeader}\n`;
} }

View File

@ -133,13 +133,13 @@ export function check(
} }
let proxyPath: string | undefined; let proxyPath: string | undefined;
if (request.headers.proxy_path) { if (request.headers.proxypath) {
try { try {
proxyPath = decodeURIComponent(request.headers.proxy_path); proxyPath = decodeURIComponent(request.headers.proxypath);
} catch (err) { } catch (err) {
log.debug('invalid proxy_path header', { proxyPath, err }); log.debug('invalid proxypath header', { proxyPath, err });
return { err: errors.InvalidArgument.customizeDescription( return { err: errors.InvalidArgument.customizeDescription(
'invalid proxy_path header') }; 'invalid proxypath header') };
} }
} }

View File

@ -57,13 +57,13 @@ export function check(request: any, log: Logger, data: { [key: string]: string }
} }
let proxyPath: string | undefined; let proxyPath: string | undefined;
if (request.headers.proxy_path) { if (request.headers.proxypath) {
try { try {
proxyPath = decodeURIComponent(request.headers.proxy_path); proxyPath = decodeURIComponent(request.headers.proxypath);
} catch (err) { } catch (err) {
log.debug('invalid proxy_path header', { proxyPath }); log.debug('invalid proxypath header', { proxyPath });
return { err: errors.InvalidArgument.customizeDescription( return { err: errors.InvalidArgument.customizeDescription(
'invalid proxy_path header') }; 'invalid proxypath header') };
} }
} }