node 4

官方文档地址:https://nodejs.org/docs/latest-v4.x/api/http.html#http_class_http_agent

Table of Contents

HTTP
Class: http.Agent
new Agent([options])
agent.destroy()
agent.freeSockets
agent.getName(options)
agent.maxFreeSockets
agent.maxSockets
agent.requests
agent.sockets
Class: http.ClientRequest
Event: ‘abort’
Event: ‘aborted’
Event: ‘connect’
Event: ‘continue’
Event: ‘response’
Event: ‘socket’
Event: ‘upgrade’
request.abort()
request.aborted
request.end([data][, encoding][, callback])
request.flushHeaders()
request.setNoDelay([noDelay])
request.setSocketKeepAlive([enable][, initialDelay])
request.setTimeout(timeout[, callback])
request.write(chunk[, encoding][, callback])
Class: http.Server
Event: ‘checkContinue’
Event: ‘clientError’
Event: ‘close’
Event: ‘connect’
Event: ‘connection’
Event: ‘request’
Event: ‘upgrade’
server.close([callback])
server.listen(handle[, callback])
server.listen(path[, callback])
server.listen([port][, hostname][, backlog][, callback])
server.maxHeadersCount
server.setTimeout(msecs, callback)
server.timeout
Class: http.ServerResponse
Event: ‘close’
Event: ‘finish’
response.addTrailers(headers)
response.end([data][, encoding][, callback])
response.finished
response.getHeader(name)
response.headersSent
response.removeHeader(name)
response.sendDate
response.setHeader(name, value)
response.setTimeout(msecs, callback)
response.statusCode
response.statusMessage
response.write(chunk[, encoding][, callback])
response.writeContinue()
response.writeHead(statusCode[, statusMessage][, headers])
Class: http.IncomingMessage
Event: ‘aborted’
Event: ‘close’
message.destroy([error])
message.headers
message.httpVersion
message.method
message.rawHeaders
message.rawTrailers
message.setTimeout(msecs, callback)
message.statusCode
message.statusMessage
message.socket
message.trailers
message.url
http.METHODS
http.STATUS_CODES
http.createClient([port][, host])
http.createServer([requestListener])
http.get(options[, callback])
http.globalAgent
http.request(options[, callback])

1、http.Agent

http agent被用作pooling sockets 用在http client 请求中
Http agent 也把Connection:keep-alive作为默认的client request。 如果套接字中pending 状态的http 请求等待释放,则这个套接字将关闭。