http2stream.pushStream(headers[, options], callback)
曆史
版本 | 變化 |
---|---|
v18.0.0 | 將無效回調傳遞給 |
v8.4.0 | 添加於:v8.4.0 |
參數
headers
<HTTP/2 Headers Object>options
<Object>callback
<Function>啟動推送流後調用的回調。err
<Error>pushStream
<ServerHttp2Stream> 返回的pushStream
對象。headers
<HTTP/2 Headers Object> Headers 對象pushStream
被啟動。
啟動推送流。使用為作為第二個參數傳遞的推送流創建的新 Http2Stream
實例或作為第一個參數傳遞的 Error
調用回調。
const http2 = require('node:http2');
const server = http2.createServer();
server.on('stream', (stream) => {
stream.respond({ ':status': 200 });
stream.pushStream({ ':path': '/' }, (err, pushStream, headers) => {
if (err) throw err;
pushStream.respond({ ':status': 200 });
pushStream.end('some pushed data');
});
stream.end('some data');
});
HEADERS
幀中不允許設置推流權重。將 weight
值傳遞給 http2stream.priority
並將 silent
選項設置為 true
以啟用並發流之間的服務器端帶寬平衡。
不允許從推送的流中調用 http2stream.pushStream()
,這將引發錯誤。
相關用法
- Node.js http2stream.pushAllowed用法及代碼示例
- Node.js http2stream.pending用法及代碼示例
- Node.js http2stream.priority()用法及代碼示例
- Node.js ServerHttp2Stream http2stream.respond([headers[, options]])用法及代碼示例
- Node.js http2stream.setTimeout()用法及代碼示例
- Node.js http2stream.id用法及代碼示例
- Node.js http2stream.closed用法及代碼示例
- Node.js http2stream.rstCode用法及代碼示例
- Node.js http2stream.sentHeaders用法及代碼示例
- Node.js http2stream.endAfterHeaders用法及代碼示例
- Node.js http2stream.headersSent用法及代碼示例
- Node.js http2stream.respond()用法及代碼示例
- Node.js http2stream.close()用法及代碼示例
- Node.js http2stream.state用法及代碼示例
- Node.js ServerHttp2Stream http2stream.respondWithFD(fd[, headers[, options]])用法及代碼示例
- Node.js ServerHttp2Stream http2stream.respondWithFile(path[, headers[, options]])用法及代碼示例
- Node.js http2stream.session用法及代碼示例
- Node.js http2stream.destroyed用法及代碼示例
- Node.js http2stream.additionalHeaders()用法及代碼示例
- Node.js http2stream.sentInfoHeaders用法及代碼示例
- Node.js http2session.destroyed用法及代碼示例
- Node.js http2session.type用法及代碼示例
- Node.js http2session.ping()用法及代碼示例
- Node.js http2session.connecting用法及代碼示例
- Node.js http2session.setTimeout()用法及代碼示例
注:本文由純淨天空篩選整理自nodejs.org大神的英文原創作品 http2stream.pushStream(headers[, options], callback)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。