Closed asherber closed 1 year ago
Is there a way to specify HTTPS in a raw file like this?
Append Port 443 to the host header. See https://github.com/AnWeber/httpyac/blob/main/src/plugins/core/replacer/hostVariableReplacer.ts#L13
Should the generated code give the whole URL on the first line, so that it includes the https?
I use httpsnippet to generate the http language code. Actually, I want to stick to their default. It would be possible that I create the code snippet myself, based on the executed request object. Imho it seems to be a bug that port 443 is not appended on host header if https is used (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host).
You could build a workaround so that https is always used for this case. Just create a .httpyac.js
file in the root of the project.
module.exports = {
configureHooks(api) {
api.hooks.replaceVariable.addHook('httpsHost', async function (text, type, { request }) {
if (typeof text === "string" && type === "url" && text.startsWith('/')) {
const host = utils.getHeader(request?.headers, 'Host');
return `https://${host}${text}`;
}
return text;
}, { before: ['host'] });
}
}
Thanks!
This HTTP file correctly sends via HTTPS:
But if I use httpyac's "generate code" feature, I get:
And if I send that request, it goes via HTTP.
https
?sendSecure
?