interceptor: mask log (#618)

This commit is contained in:
Pacalini
2025-11-29 14:21:30 +08:00
committed by GitHub
parent 7e3addf7a6
commit da5b64abb0
3 changed files with 45 additions and 15 deletions

View File

@@ -465,9 +465,10 @@ let Network = {
* @param {string} url - The URL to send the request to.
* @param {Object} headers - The headers to include in the request.
* @param data - The data to send with the request.
* @param {Object} extra - Extra options to pass to the interceptor.
* @returns {Promise<{status: number, headers: {}, body: ArrayBuffer}>} The response from the request.
*/
async fetchBytes(method, url, headers, data) {
async fetchBytes(method, url, headers, data, extra) {
let result = await sendMessage({
method: 'http',
http_method: method,
@@ -475,6 +476,7 @@ let Network = {
url: url,
headers: headers,
data: data,
extra: extra,
});
if (result.error) {
@@ -490,15 +492,17 @@ let Network = {
* @param {string} url - The URL to send the request to.
* @param {Object} headers - The headers to include in the request.
* @param data - The data to send with the request.
* @param {Object} extra - Extra options to pass to the interceptor.
* @returns {Promise<{status: number, headers: {}, body: string}>} The response from the request.
*/
async sendRequest(method, url, headers, data) {
async sendRequest(method, url, headers, data, extra) {
let result = await sendMessage({
method: 'http',
http_method: method,
url: url,
headers: headers,
data: data,
extra: extra,
});
if (result.error) {
@@ -512,10 +516,11 @@ let Network = {
* Sends an HTTP GET request.
* @param {string} url - The URL to send the request to.
* @param {Object} headers - The headers to include in the request.
* @param {Object} extra - Extra options to pass to the interceptor.
* @returns {Promise<{status: number, headers: {}, body: string}>} The response from the request.
*/
async get(url, headers) {
return this.sendRequest('GET', url, headers);
async get(url, headers, extra) {
return this.sendRequest('GET', url, headers, extra);
},
/**
@@ -523,10 +528,11 @@ let Network = {
* @param {string} url - The URL to send the request to.
* @param {Object} headers - The headers to include in the request.
* @param data - The data to send with the request.
* @param {Object} extra - Extra options to pass to the interceptor.
* @returns {Promise<{status: number, headers: {}, body: string}>} The response from the request.
*/
async post(url, headers, data) {
return this.sendRequest('POST', url, headers, data);
async post(url, headers, data, extra) {
return this.sendRequest('POST', url, headers, data, extra);
},
/**
@@ -534,10 +540,11 @@ let Network = {
* @param {string} url - The URL to send the request to.
* @param {Object} headers - The headers to include in the request.
* @param data - The data to send with the request.
* @param {Object} extra - Extra options to pass to the interceptor.
* @returns {Promise<{status: number, headers: {}, body: string}>} The response from the request.
*/
async put(url, headers, data) {
return this.sendRequest('PUT', url, headers, data);
async put(url, headers, data, extra) {
return this.sendRequest('PUT', url, headers, data, extra);
},
/**
@@ -545,20 +552,22 @@ let Network = {
* @param {string} url - The URL to send the request to.
* @param {Object} headers - The headers to include in the request.
* @param data - The data to send with the request.
* @param {Object} extra - Extra options to pass to the interceptor.
* @returns {Promise<{status: number, headers: {}, body: string}>} The response from the request.
*/
async patch(url, headers, data) {
return this.sendRequest('PATCH', url, headers, data);
async patch(url, headers, data, extra) {
return this.sendRequest('PATCH', url, headers, data, extra);
},
/**
* Sends an HTTP DELETE request.
* @param {string} url - The URL to send the request to.
* @param {Object} headers - The headers to include in the request.
* @param {Object} extra - Extra options to pass to the interceptor.
* @returns {Promise<{status: number, headers: {}, body: string}>} The response from the request.
*/
async delete(url, headers) {
return this.sendRequest('DELETE', url, headers);
async delete(url, headers, extra) {
return this.sendRequest('DELETE', url, headers, extra);
},
/**