阿西河

所有教程

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

我的收藏

    最近访问  (文章)

      教程列表

      抓包专区
      测试专区

      Node.js http2 response.write

      Node.js http2 response.write(chunk[, encoding][, callback])

      新增于: v8.4.0

      • chunk < string> | < Buffer>
      • encoding < string>
      • callback < Function>
      • Returns: < boolean>

      If this method is called and response.writeHead() has not been called, it will switch to implicit header mode and flush the implicit headers.

      This sends a chunk of the response body. This method may be called multiple times to provide successive parts of the body.

      Note that in the http module, the response body is omitted when the request is a HEAD request. Similarly, the 204 and 304 responses must not include a message body.

      chunk can be a string or a buffer. If chunk is a string, the second parameter specifies how to encode it into a byte stream. By default the encoding is ‘utf8’. callback will be called when this chunk of data is flushed.

      This is the raw HTTP body and has nothing to do with higher-level multi-part body encodings that may be used.

      The first time response.write() is called, it will send the buffered header information and the first chunk of the body to the client. The second time response.write() is called, Node.js assumes data will be streamed, and sends the new data separately. That is, the response is buffered up to the first chunk of the body.

      Returns true if the entire data was flushed successfully to the kernel buffer. Returns false if all or part of the data was queued in user memory. ‘drain’ will be emitted when the buffer is free again.


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


      目录
      本文目录
      目录