# HTTP

# Functions

  • isHttps()

    判断url是否是https

  • combineUrlAndParams()

    将data对象的数据以key=value的方式合并到url之后,并返回合并之后的url。

  • sign(data, secret)string

    对http请求数据签名,内部采用MD5算法生成签名指纹。

  • 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.

  • eachHeader()

    Iterator function for the request/response's "headers". Invokes fn for "each" header entry in the request.

  • 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.

  • requestAuthorization()

    Sends a "407 Proxy Authentication Required" HTTP response to the socket.

  • webapp()

    创建一个基于koa2的web应用。

  • body()

    创建一个body解析器中间件,详细选项设置请参考body模块。

  • send()

    发送http响应

  • sendFile()

    发送响应文件。

  • handler()

    将func函数包装成一个中间件

# isHttps()

判断url是否是https

Kind: global function

# combineUrlAndParams()

将data对象的数据以key=value的方式合并到url之后,并返回合并之后的url。

Kind: global function

# sign(data, secret) ⇒ string

对http请求数据签名,内部采用MD5算法生成签名指纹。

Kind: global function Returns: string - 签名指纹

Param Type Description
data object 用于签名的http请求数据。
secret string 用于签名的密钥。

# getRequestOptions()

将url解析成通用的请求选项参数。

Kind: global function

# request()

发起一次HTTP请求

Kind: global function

# get()

发起一次HTTP的GET请求。

Kind: global function

# post()

发起一次HTTP的POST请求。

Kind: global function

# call()

调用一次HTTP接口。HTTP接口统一采用POST方式进行通讯。

Kind: global function

# makeRPC()

定义一组以base地址开头的接口列表,返回接口对象。接口对象会被转换成驼峰命名。

Kind: global function

# rpc()

定义一组以base地址开头的接口列表,返回接口对象。接口对象会被转换成驼峰命名。

Kind: global function

# 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.

Kind: global function

# onconnect()

HTTP CONNECT proxy requests.

Kind: global function

# 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应用。

Kind: global function

# body()

创建一个body解析器中间件,详细选项设置请参考body模块。

Kind: global function

# send()

发送http响应

Kind: global function

# sendFile()

发送响应文件。

Kind: global function

# handler()

将func函数包装成一个中间件

Kind: global function