summaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorHaishan <[email protected]>2020-01-04 16:56:53 +0800
committerHaishan <[email protected]>2020-01-04 16:56:53 +0800
commit85d948def8e1a75c5e5cce2d5518e9702b6e0452 (patch)
tree796865645a1137338a310a0b8f1625d890d3c939 /src/api
parenta06a32131759cd3b34000cfd5a098df875fddae7 (diff)
feat: support change latency test url #286
Diffstat (limited to 'src/api')
-rw-r--r--src/api/proxies.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/api/proxies.js b/src/api/proxies.js
index 8242580..72e1c52 100644
--- a/src/api/proxies.js
+++ b/src/api/proxies.js
@@ -4,9 +4,6 @@ const endpoint = '/proxies';
/*
$ curl "http://127.0.0.1:8080/proxies/Proxy" -XPUT -d '{ "name": "ss3" }' -i
HTTP/1.1 400 Bad Request
-Vary: Origin
-Date: Tue, 16 Oct 2018 16:38:20 GMT
-Content-Length: 56
Content-Type: text/plain; charset=utf-8
{"error":"Selector update error: Proxy does not exist"}
@@ -14,8 +11,6 @@ Content-Type: text/plain; charset=utf-8
~
$ curl "http://127.0.0.1:8080/proxies/GLOBAL" -XPUT -d '{ "name": "Proxy" }' -i
HTTP/1.1 204 No Content
-Vary: Origin
-Date: Tue, 16 Oct 2018 16:38:33 GMT
*/
export async function fetchProxies(config) {
@@ -35,9 +30,13 @@ export async function requestToSwitchProxy(apiConfig, name1, name2) {
});
}
-export async function requestDelayForProxy(apiConfig, name) {
+export async function requestDelayForProxy(
+ apiConfig,
+ name,
+ latencyTestUrl = 'http://www.gstatic.com/generate_204'
+) {
const { url, init } = getURLAndInit(apiConfig);
- const qs = 'timeout=5000&url=http://www.google.com/generate_204';
+ const qs = `timeout=5000&url=${latencyTestUrl}`;
const fullURL = `${url}${endpoint}/${name}/delay?${qs}`;
return await fetch(fullURL, init);
}