diff --git a/.DS_Store b/.DS_Store index 5f3d46b..8d71766 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/4.x/assets/css/custom.css b/4.x/assets/css/custom.css index 5658f6d..b8f01c6 100644 --- a/4.x/assets/css/custom.css +++ b/4.x/assets/css/custom.css @@ -30,7 +30,9 @@ body{ .toc-container{ width: 200px; position: fixed; - top: 42px; + top: 20px; + height: 95vh; + overflow-y: auto; } .toc-container ul{ diff --git a/4.x/assets/css/hljs-github.min.css b/4.x/assets/css/hljs-github.min.css deleted file mode 100644 index cb2cc27..0000000 --- a/4.x/assets/css/hljs-github.min.css +++ /dev/null @@ -1,96 +0,0 @@ -/* - -Atom One Light by Daniel Gamage -Original One Light Syntax theme from https://github.com/atom/one-light-syntax - -base: #fafafa -mono-1: #383a42 -mono-2: #686b77 -mono-3: #a0a1a7 -hue-1: #0184bb -hue-2: #4078f2 -hue-3: #a626a4 -hue-4: #50a14f -hue-5: #e45649 -hue-5-2: #c91243 -hue-6: #986801 -hue-6-2: #c18401 - -*/ - -.hljs { - display: block; - overflow-x: auto; - padding: 0.5em; - color: #383a42; - background: #fafafa; -} - -.hljs-comment, -.hljs-quote { - color: #a0a1a7; - font-style: italic; -} - -.hljs-doctag, -.hljs-keyword, -.hljs-formula { - color: #a626a4; -} - -.hljs-section, -.hljs-name, -.hljs-selector-tag, -.hljs-deletion, -.hljs-subst { - color: #e45649; -} - -.hljs-literal { - color: #0184bb; -} - -.hljs-string, -.hljs-regexp, -.hljs-addition, -.hljs-attribute, -.hljs-meta-string { - color: #50a14f; -} - -.hljs-built_in, -.hljs-class .hljs-title { - color: #c18401; -} - -.hljs-attr, -.hljs-variable, -.hljs-template-variable, -.hljs-type, -.hljs-selector-class, -.hljs-selector-attr, -.hljs-selector-pseudo, -.hljs-number { - color: #986801; -} - -.hljs-symbol, -.hljs-bullet, -.hljs-link, -.hljs-meta, -.hljs-selector-id, -.hljs-title { - color: #4078f2; -} - -.hljs-emphasis { - font-style: italic; -} - -.hljs-strong { - font-weight: bold; -} - -.hljs-link { - text-decoration: underline; -} \ No newline at end of file diff --git a/4.x/index.html b/4.x/index.html index 3d22551..3ee1e84 100644 --- a/4.x/index.html +++ b/4.x/index.html @@ -29,11 +29,19 @@
当http请求经过代理服务器时,代理服务器的处理流程是:
+当http请求经过代理服务器时,代理服务器的具体流程是:
beforeSendRequest
方法,由模块做处理,返回新的请求参数,或返回响应内容完整的请求处理流程如下,供参考
-如下几种方案都可以用来引用规则模块:
anyproxy --rule ./myRulePkg/ #本地包
npm i -g myRulePkg && anyproxy --rule myRulePkg #全局包
规则模块应该符合cmd规范,一个典型的规则模块代码结构如下
+规则模块应该符合cmd规范,一个典型的规则模块代码结构如下。模块中所有方法都是可选的,只需实现业务感兴趣的部分即可。
module.exports = {
- summary() { return 'my customized rule for AnyProxy'; },
- *beforeSendRequest(requestDetail) { /* ... */ },
- *beforeSendResponse(requestDetail, responseDetail) { /* ... */ },
- *beforeDealHttpsRequest(requestDetail) { /* ... */ }
-};
beforeSendRequest
,并带上参数requestDetail
{
protocol: 'http',
url: 'http://anyproxy.io/',
@@ -266,14 +285,17 @@ newOption.path = '/redirect/to/another/path';
requestData: 'my new request data'
//这里也可以同时加上requestOptions
};
statusCode
header
是必选字段return {
- statusCode: 200,
- header: { 'content-type': 'text/html' },
- body: 'this could be a <string> or <buffer>'
+ response: {
+ statusCode: 200,
+ header: { 'content-type': 'text/html' },
+ body: 'this could be a <string> or <buffer>'
+ }
};
beforeSendResponse
,并带上参数requestDetail
responseDetail
_res
{object} 原始的服务端返回对象举例,请求 anyproxy.io 时,responseDetail
参数内容大致如下
{
+ response: {
+ statusCode: 200,
+ header: {
+ 'Content-Type': 'image/gif',
+ Connection: 'close',
+ 'Cache-Control': '...'
+ },
+ body: '...'
+ },
+ _res: { /* ... */ }
+}
以下几种返回都是合法的
beforeDealHttpsRequest
,并带上参数requestDetail
true
或者false
,是否需要AnyProxy解析httpstrue
或者false
,表示是否需要AnyProxy替换证书并解析httpsonError
方法,并提供对应的错误信息requestDetail
同beforeSendRequest
中的参数以下几种返回都是合法的
+return null;
return {
+ response: {
+ statusCode: 200,
+ header: { 'content-type': 'text/html' },
+ body: 'this could be a <string> or <buffer>'
+ }
+};
requestDetail
同beforeDealHttpsRequest
中的参数