aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorMatthew Shao <me@matshao.com>2017-08-12 19:36:43 +0800
committerMatthew Shao <me@matshao.com>2017-08-12 19:36:43 +0800
commite925015d10e554534b64f8b9fc16588a4c90fde1 (patch)
tree1c43cfb6e4b845dc404314e526fe30aa55dd2a23 /web
parent1b129b50990ce253f2b9e96902ef2330e804162e (diff)
downloadmitmproxy-e925015d10e554534b64f8b9fc16588a4c90fde1.tar.gz
mitmproxy-e925015d10e554534b64f8b9fc16588a4c90fde1.tar.bz2
mitmproxy-e925015d10e554534b64f8b9fc16588a4c90fde1.zip
[web] Update fetch api to suite the static mode.
Diffstat (limited to 'web')
-rw-r--r--web/src/js/flow/utils.js9
-rw-r--r--web/src/js/utils.js16
2 files changed, 23 insertions, 2 deletions
diff --git a/web/src/js/flow/utils.js b/web/src/js/flow/utils.js
index 3c38058e..9d4e1012 100644
--- a/web/src/js/flow/utils.js
+++ b/web/src/js/flow/utils.js
@@ -49,7 +49,14 @@ export var MessageUtils = {
} else if (message === flow.response) {
message = "response";
}
- return `/flows/${flow.id}/${message}/content` + (view ? `/${view}` : '');
+ if (global.MITMWEB_STATIC) {
+ let url = view ?
+ `/flows/${flow.id}/${message}/content/${view}` :
+ `/flows/${flow.id}/${message}/_content`
+ return url;
+ } else {
+ return `/flows/${flow.id}/${message}/content` + (view ? `/${view}` : '');
+ }
}
};
diff --git a/web/src/js/utils.js b/web/src/js/utils.js
index e8470cec..68daa1ad 100644
--- a/web/src/js/utils.js
+++ b/web/src/js/utils.js
@@ -81,7 +81,21 @@ function getCookie(name) {
}
const xsrf = `_xsrf=${getCookie("_xsrf")}`;
+
export function fetchApi(url, options={}) {
+ if (global.MITMWEB_STATIC) {
+ let path = url.split('/'),
+ filename = path.pop()
+ filename = '_' + filename
+ path.push(filename)
+ let new_url = path.join('/')
+ return _fetchApi(new_url, options)
+ } else {
+ return _fetchApi(url, options)
+ }
+}
+
+function _fetchApi(url, options={}) {
if (options.method && options.method !== "GET") {
if (url.indexOf("?") === -1) {
url += "?" + xsrf;
@@ -96,7 +110,7 @@ export function fetchApi(url, options={}) {
});
}
-fetchApi.put = (url, json, options) => fetchApi(
+fetchApi.put = (url, json, options) => _fetchApi(
url,
{
method: "PUT",