/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** * Clone request by id. Used when cloning a request * through the "Edit and Resend" option present in the context menu.
*/ function cloneRequest(id) { return {
id,
type: CLONE_REQUEST,
};
}
/** * Right click a request without selecting it.
*/ function rightClickRequest(id) { return {
id,
type: RIGHT_CLICK_REQUEST,
};
}
/** * Clone the currently selected request, set the "isCustom" attribute. * Used by the "Edit and Resend" feature.
*/ function cloneSelectedRequest() { return {
type: CLONE_SELECTED_REQUEST,
};
}
/** * Send a new HTTP request using the data in the custom request form.
*/ function sendCustomRequest(requestId = null) { return async ({ dispatch, getState, connector, commands }) => {
let request; if (requestId) {
request = getRequestById(getState(), requestId);
} else {
request = getSelectedRequest(getState());
}
if (!request) { return;
}
// Fetch request headers and post data from the backend.
await fetchNetworkUpdatePacket(connector.requestData, request, [ "requestHeaders", "requestPostData",
]);
// Reload the request from the store to get the headers.
request = getRequestById(getState(), request.id);
// Send a new HTTP request using the data in the custom request form const data = {
cause: request.cause,
url: request.url,
method: request.method,
httpVersion: request.httpVersion,
};
if (request.requestHeaders) {
data.headers = request.requestHeaders.headers;
}
if (request.requestPostData) {
data.body = request.requestPostData.postData.text;
}
/** * Remove a request from the list. Supports removing only cloned requests with a * "isCustom" attribute. Other requests never need to be removed.
*/ function removeSelectedCustomRequest() { return {
type: REMOVE_SELECTED_CUSTOM_REQUEST,
};
} /** * Clear all requests * * @param {object} options * @param {boolean} options.isExplicitClear * Set to true if the call to clear requests is explicitly requested by the * user, to false if this is an automated clear, eg on navigation.
*/ function clearRequests({ isExplicitClear }) { return ({ dispatch, connector }) => {
dispatch({ type: CLEAR_REQUESTS });
connector.clear({ isExplicitClear });
};
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.