# HTTP
# Functions
-
判断url是否是https
-
将data对象的数据以key=value的方式合并到url之后,并返回合并之后的url。
sign(data, secret) ⇒
string对http请求数据签名,内部采用MD5算法生成签名指纹。
-
将url解析成通用的请求选项参数。
-
发起一次HTTP请求
-
发起一次HTTP的GET请求。
-
发起一次HTTP的POST请求。
-
调用一次HTTP接口。HTTP接口统一采用POST方式进行通讯。
-
定义一组以base地址开头的接口列表,返回接口对象。接口对象会被转换成驼峰命名。
-
定义一组以base地址开头的接口列表,返回接口对象。接口对象会被转换成驼峰命名。
setup(proxyServer, proxyOptions)
Sets up an
http.Serverorhttps.Serverinstance with the necessary "request" and "connect" event listeners in order to make the server act as an HTTP proxy.-
Iterator function for the request/response's "headers". Invokes
fnfor "each" header entry in the request. -
HTTP GET/POST/DELETE/PUT, etc. proxy requests.
-
HTTP CONNECT proxy requests.
-
Checks
Proxy-Authorizationrequest headers. Same logic applied to CONNECT requests as well as regular HTTP requests. -
Sends a "407 Proxy Authentication Required" HTTP response to the
socket. -
创建一个基于koa2的web应用。
-
创建一个body解析器中间件,详细选项设置请参考body模块。
-
发送http响应
-
发送响应文件。
-
将func函数包装成一个中间件
# isHttps()
判断url是否是https
# combineUrlAndParams()
将data对象的数据以key=value的方式合并到url之后,并返回合并之后的url。
# sign(data, secret) ⇒ string
对http请求数据签名,内部采用MD5算法生成签名指纹。
Kind: global function Returns: string - 签名指纹
| Param | Type | Description |
|---|---|---|
| data | object | 用于签名的http请求数据。 |
| secret | string | 用于签名的密钥。 |
# getRequestOptions()
将url解析成通用的请求选项参数。
# request()
发起一次HTTP请求
# get()
发起一次HTTP的GET请求。
# post()
发起一次HTTP的POST请求。
# call()
调用一次HTTP接口。HTTP接口统一采用POST方式进行通讯。
# makeRPC()
定义一组以base地址开头的接口列表,返回接口对象。接口对象会被转换成驼峰命名。
# rpc()
定义一组以base地址开头的接口列表,返回接口对象。接口对象会被转换成驼峰命名。
# setup(proxyServer, proxyOptions)
Sets up an http.Server or https.Server instance with the necessary "request" and "connect" event listeners in order to make the server act as an HTTP proxy.
Kind: global function Api: public
| Param | Type |
|---|---|
| proxyServer | http.Server |
| proxyOptions | Object |
# eachHeader()
Iterator function for the request/response's "headers". Invokes fn for "each" header entry in the request.
Kind: global function Api: private
# onrequest()
HTTP GET/POST/DELETE/PUT, etc. proxy requests.
# onconnect()
HTTP CONNECT proxy requests.
# authenticate(server, req, fn)
Checks Proxy-Authorization request headers. Same logic applied to CONNECT requests as well as regular HTTP requests.
Kind: global function Api: private
| Param | Type | Description |
|---|---|---|
| server | http.Server | |
| req | http.ServerRequest | |
| fn | function | callback function |
# requestAuthorization()
Sends a "407 Proxy Authentication Required" HTTP response to the socket.
Kind: global function Api: private
# webapp()
创建一个基于koa2的web应用。
# body()
创建一个body解析器中间件,详细选项设置请参考body模块。
# send()
发送http响应
# sendFile()
发送响应文件。
# handler()
将func函数包装成一个中间件
Kind: global function
Authes →