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