Skip to content

Commit

Permalink
Allow custom HTTP headers
Browse files Browse the repository at this point in the history
  • Loading branch information
ioppermann committed Oct 25, 2024
1 parent e35dac1 commit 8958f47
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/views/Edit/Sources/Network.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const initSettings = (initialSettings, config) => {
userAgent: '',
referer: '',
http_proxy: '',
headers: '',
...settings.http,
};

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 8958f47

Please sign in to comment.