阿西河

所有教程

公众号
🌙
阿西河前端的公众号

我的收藏

    最近访问  (文章)

      教程列表

      抓包专区
      测试专区

      Node.js http2.connect

      Node.js http2.connect(authority[, options][, listener])

      版本历史

      版本变更
      v8.9.3Added the maxOutstandingPings option with a default limit of 10.
      v8.9.3Added the maxHeaderListPairs option with a default limit of 128 header pairs.
      v8.4.0新增于: v8.4.0
      • authority < string> | < URL>

      • options < Object>

        • maxDeflateDynamicTableSize < number> Sets the maximum dynamic table size for deflating header fields. Default: 4Kib.

        • maxSessionMemory< number> Sets the maximum memory that the Http2Session is permitted to use. The value is expressed in terms of number of megabytes, e.g. 1 equal 1 megabyte. The minimum value allowed is 1. This is a credit based limit, existing Http2Streams may cause this limit to be exceeded, but new Http2Stream instances will be rejected while this limit is exceeded. The current number of Http2Stream sessions, the current memory use of the header compression tables, current data queued to be sent, and unacknowledged PING and SETTINGS frames are all counted towards the current limit. Default: 10.

        • maxHeaderListPairs < number> Sets the maximum number of header entries. The minimum value is 1. Default: 128.

        • maxOutstandingPings < number> Sets the maximum number of outstanding, unacknowledged pings. Default: 10.

        • maxReservedRemoteStreams < number> Sets the maximum number of reserved push streams the client will accept at any given time. Once the current number of currently reserved push streams exceeds reaches this limit, new push streams sent by the server will be automatically rejected.

        • maxSendHeaderBlockLength < number> Sets the maximum allowed size for a serialized, compressed block of headers. Attempts to send headers that exceed this limit will result in a ‘frameError’ event being emitted and the stream being closed and destroyed.

        • paddingStrategy < number> Identifies the strategy used for determining the amount of padding to use for HEADERS and DATA frames. Default: http2.constants.PADDING_STRATEGY_NONE. Value may be one of:

          • http2.constants.PADDING_STRATEGY_NONE - Specifies that no padding is to be applied.
          • http2.constants.PADDING_STRATEGY_MAX - Specifies that the maximum amount of padding, as determined by the internal implementation, is to be applied.
          • http2.constants.PADDING_STRATEGY_CALLBACK - Specifies that the user provided options.selectPadding() callback is to be used to determine the amount of padding.
          • http2.constants.PADDING_STRATEGY_ALIGNED - Will attempt to apply enough padding to ensure that the total frame length, including the 9-byte header, is a multiple of 8. For each frame, however, there is a maximum allowed number of padding bytes that is determined by current flow control state and settings. If this maximum is less than the calculated amount needed to ensure alignment, the maximum will be used and the total frame length will not necessarily be aligned at 8 bytes.
        • peerMaxConcurrentStreams < number> Sets the maximum number of concurrent streams for the remote peer as if a SETTINGS frame had been received. Will be overridden if the remote peer sets its own value for maxConcurrentStreams. Default: 100.

        • selectPadding < Function> When options.paddingStrategy is equal to http2.constants.PADDING_STRATEGY_CALLBACK, provides the callback function used to determine the padding. See Using options.selectPadding().

        • settings < HTTP/2 Settings Object> The initial settings to send to the remote peer upon connection.

        • createConnection < Function> An optional callback that receives the URL instance passed to connect and the options object, and returns any Duplex stream that is to be used as the connection for this session.

        • …: Any net.connect() or tls.connect() options can be provided.

      • listener < Function>

      • Returns:

      Returns a ClientHttp2Session instance.

      const http2 = require('http2');
      const client = http2.connect('https://localhost:1234');
      
      /* Use the client */
      
      client.close();
      

      更多内容请参考:Node.js HTTP2,或者通过 点击对应菜单 进行查看;


      目录
      本文目录
      目录