mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-23 00:13:24 +01:00
Merge pull request #590 from snippetkid/557-configurable-request-timeout
Configurable request timeout
This commit is contained in:
commit
4c8ebe7765
@ -4,7 +4,7 @@ const StyledWrapper = styled.div`
|
||||
div.CodeMirror {
|
||||
background: ${(props) => props.theme.codemirror.bg};
|
||||
border: solid 1px ${(props) => props.theme.codemirror.border};
|
||||
font-family: ${(props) => props.font ? props.font : "default"};
|
||||
font-family: ${(props) => (props.font ? props.font : 'default')};
|
||||
}
|
||||
|
||||
.CodeMirror-overlayscroll-horizontal div,
|
||||
|
@ -8,13 +8,15 @@ const General = ({ close }) => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const [sslVerification, setSslVerification] = useState(preferences.request.sslVerification);
|
||||
const [timeout, setTimeout] = useState(preferences.request.timeout);
|
||||
|
||||
const handleSave = () => {
|
||||
dispatch(
|
||||
savePreferences({
|
||||
...preferences,
|
||||
request: {
|
||||
sslVerification
|
||||
sslVerification,
|
||||
timeout
|
||||
}
|
||||
})
|
||||
).then(() => {
|
||||
@ -22,19 +24,35 @@ const General = ({ close }) => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleTimeoutChange = (value) => {
|
||||
const validTimeout = isNaN(Number(value)) ? timeout : Number(value);
|
||||
setTimeout(validTimeout);
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledWrapper>
|
||||
<div className="flex items-center mt-2">
|
||||
<label className="mr-2" style={{ minWidth: 200 }} htmlFor="ssl-cert-verification">
|
||||
SSL Certificate Verification
|
||||
</label>
|
||||
<input
|
||||
id="ssl-verification"
|
||||
id="ssl-cert-verification"
|
||||
type="checkbox"
|
||||
checked={sslVerification}
|
||||
onChange={() => setSslVerification(!sslVerification)}
|
||||
className="mr-3 mousetrap"
|
||||
className="mousetrap h-4 w-4 mr-0"
|
||||
/>
|
||||
<label htmlFor="ssl-verification" className="select-none">
|
||||
SSL Certificate Verification
|
||||
</div>
|
||||
<div className="flex items-center mt-2">
|
||||
<label className="mr-2" style={{ minWidth: 200 }}>
|
||||
Request Timeout (in ms)
|
||||
</label>
|
||||
<input
|
||||
value={timeout === 0 ? '' : timeout}
|
||||
onChange={(e) => handleTimeoutChange(e.target.value)}
|
||||
type="text"
|
||||
className="block textbox w-1/6"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="mt-10">
|
||||
|
@ -206,6 +206,8 @@ const registerNetworkIpc = (mainWindow) => {
|
||||
});
|
||||
|
||||
const preferences = getPreferences();
|
||||
const timeout = get(preferences, 'request.timeout', 0);
|
||||
request.timeout = timeout;
|
||||
const sslVerification = get(preferences, 'request.sslVerification', true);
|
||||
const httpsAgentRequestFields = {};
|
||||
if (!sslVerification) {
|
||||
@ -517,6 +519,8 @@ const registerNetworkIpc = (mainWindow) => {
|
||||
const preparedRequest = prepareGqlIntrospectionRequest(endpoint, envVars, request, collectionRoot);
|
||||
|
||||
const preferences = getPreferences();
|
||||
const timeout = get(preferences, 'request.timeout', 0);
|
||||
request.timeout = timeout;
|
||||
const sslVerification = get(preferences, 'request.sslVerification', true);
|
||||
|
||||
if (!sslVerification) {
|
||||
@ -695,6 +699,8 @@ const registerNetworkIpc = (mainWindow) => {
|
||||
});
|
||||
|
||||
const preferences = getPreferences();
|
||||
const timeout = get(preferences, 'request.timeout', 0);
|
||||
request.timeout = timeout;
|
||||
const sslVerification = get(preferences, 'request.sslVerification', true);
|
||||
|
||||
// proxy configuration
|
||||
|
@ -3,7 +3,8 @@ const Store = require('electron-store');
|
||||
|
||||
const defaultPreferences = {
|
||||
request: {
|
||||
sslVerification: true
|
||||
sslVerification: true,
|
||||
timeout: 0
|
||||
},
|
||||
font: {
|
||||
codeFont: 'default'
|
||||
@ -12,7 +13,8 @@ const defaultPreferences = {
|
||||
|
||||
const preferencesSchema = Yup.object().shape({
|
||||
request: Yup.object().shape({
|
||||
sslVerification: Yup.boolean()
|
||||
sslVerification: Yup.boolean(),
|
||||
timeout: Yup.number()
|
||||
}),
|
||||
font: Yup.object().shape({
|
||||
codeFont: Yup.string().nullable()
|
||||
|
@ -5,6 +5,7 @@ class BrunoRequest {
|
||||
this.method = req.method;
|
||||
this.headers = req.headers;
|
||||
this.body = req.data;
|
||||
this.timeout = req.timeout;
|
||||
}
|
||||
|
||||
getUrl() {
|
||||
@ -50,6 +51,14 @@ class BrunoRequest {
|
||||
setMaxRedirects(maxRedirects) {
|
||||
this.req.maxRedirects = maxRedirects;
|
||||
}
|
||||
|
||||
getTimeout() {
|
||||
return this.req.timeout;
|
||||
}
|
||||
|
||||
setTimeout(timeout) {
|
||||
this.req.timeout = timeout;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BrunoRequest;
|
||||
|
Loading…
Reference in New Issue
Block a user