Allow custom HTTP headers

This commit is contained in:
Ingo Oppermann 2024-10-25 16:18:12 +02:00
parent e35dac1137
commit 8958f47462
No known key found for this signature in database
GPG Key ID: 2AB32426E9DD229E

View File

@ -74,6 +74,7 @@ const initSettings = (initialSettings, config) => {
userAgent: '',
referer: '',
http_proxy: '',
headers: '',
...settings.http,
};
@ -293,6 +294,15 @@ const createInputs = (settings, config, skills) => {
input.options.push('-referer', settings.http.referer);
}
if (settings.http.headers.length !== 0) {
let headers = settings.http.headers
.split('\n')
.map((l) => l.trim())
.filter((l) => l.length > 0)
.join('\r\n');
input.options.push('-headers', headers + '\r\n');
}
if (settings.http.http_proxy.length !== 0) {
input.options.push('-http_proxy', settings.http.http_proxy);
}
@ -605,6 +615,19 @@ function AdvancedSettings({ settings = {}, onChange = function (settings) {} })
onChange={onChange('http', 'referer')}
/>
</Grid>
<Grid item xs={12}>
<TextField
variant="outlined"
fullWidth
multiline
label="Headers"
value={settings.http.headers}
onChange={onChange('http', 'headers')}
/>
<Typography variant="caption">
<Trans>List of additional HTTP headers, one per line.</Trans>
</Typography>
</Grid>
<Grid item xs={12}>
<TextField
variant="outlined"