美文网首页
20160808周国康-Http协议

20160808周国康-Http协议

作者: ZGKzm | 来源:发表于2016-08-09 16:44 被阅读0次

    http请求:

        option           数组对象,包含以下参数:
        host:            表示请求网站的域名或IP地址(请求的地址)。 默认为'localhost'。
        hostname:        服务器名称,主机名是首选的值。
        port:            请求网站的端口,默认为 80。
        localAddress:    建立网络连接的本地
        socketPath:      Unix Domain Socket(Domain套接字路径)
        method:          HTTP请求方法,默认是 ‘GET'。
        path:            请求的相对于根的路径,默认是'/'。QueryString应该包含在其中。例如:/index.html?page=12
        headers:         请求头对象。
        auth:            Basic认证(基本身份验证),这个值将被计算成请求头中的 Authorization 部分。
        callback :       回调,传递一个参数,为 http.ClientResponse的实例。http.request 返回一个 http.ClientRequest 的实例。
    
      headers:
         { host: '192.168.127.132:1337',//主机地址
           connection: 'keep-alive',//长链接
           'cache-control': 'max-age=0',//控制缓存
           accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',//请求头 类型
           'upgrade-insecure-requests': '1',//自动升级请求https
           'user-agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36',//用户系统信息
           'accept-encoding': 'gzip, deflate, sdch',//编码类型
           'accept-language': 'zh-CN,zh;q=0.8' },//编码语言
    

    ServerResponse

           ServerResponse {
             domain: null,//域
             _events: [Object],//事件集
             _eventsCount: 1,//事件计数
             _maxListeners: undefined,//最大监听数
             output: [],//响应流文本输出
             outputEncodings: [],//编码
             outputCallbacks: [],//回调
             outputSize: 0,//大小
             writable: true,//可写
             _last: false,//
             chunkedEncoding: true,//
             shouldKeepAlive: true,//是否保持连接
             useChunkedEncodingByDefault: true,//
             sendDate: true,//
             _removedHeader: {},//
             _contentLength: null,//内容长度
             _hasBody: true,//
             _trailer: '',//
             finished: false,//
             _headerSent: false,//
             socket: [Circular],//
             connection: [Circular],//
             _header: 'HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nDate: Tue, 09 Aug 2016 02:24:03 GMT\r\nConnection: keep-alive\r\nTransfer-Encoding: chunked\r\n\r\n',//报头
             _headers: null,//
             _headerNames: {},//
             _onPendingData: [Function: updateOutgoingData],//
             statusMessage: 'OK',//
             statusCode: 200 } },//
    

    相关文章

      网友评论

          本文标题:20160808周国康-Http协议

          本文链接:https://www.haomeiwen.com/subject/nwjdsttx.html