summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/node/ops/http2.rs16
-rw-r--r--ext/node/polyfills/http2.ts10
2 files changed, 18 insertions, 8 deletions
diff --git a/ext/node/ops/http2.rs b/ext/node/ops/http2.rs
index b89990e0b..e0de8e474 100644
--- a/ext/node/ops/http2.rs
+++ b/ext/node/ops/http2.rs
@@ -423,7 +423,7 @@ pub struct Http2ClientResponse {
pub async fn op_http2_client_get_response(
state: Rc<RefCell<OpState>>,
#[smi] stream_rid: ResourceId,
-) -> Result<Http2ClientResponse, AnyError> {
+) -> Result<(Http2ClientResponse, bool), AnyError> {
let resource = state
.borrow()
.resource_table
@@ -439,6 +439,7 @@ pub async fn op_http2_client_get_response(
for (key, val) in parts.headers.iter() {
res_headers.push((key.as_str().into(), val.as_bytes().into()));
}
+ let end_stream = body.is_end_stream();
let (trailers_tx, trailers_rx) = tokio::sync::oneshot::channel();
let body_rid =
@@ -450,11 +451,14 @@ pub async fn op_http2_client_get_response(
trailers_rx: AsyncRefCell::new(Some(trailers_rx)),
trailers_tx: AsyncRefCell::new(Some(trailers_tx)),
});
- Ok(Http2ClientResponse {
- headers: res_headers,
- body_rid,
- status_code: status.into(),
- })
+ Ok((
+ Http2ClientResponse {
+ headers: res_headers,
+ body_rid,
+ status_code: status.into(),
+ },
+ end_stream,
+ ))
}
enum DataOrTrailers {
diff --git a/ext/node/polyfills/http2.ts b/ext/node/polyfills/http2.ts
index b9d9f4b06..59756dd0f 100644
--- a/ext/node/polyfills/http2.ts
+++ b/ext/node/polyfills/http2.ts
@@ -822,7 +822,7 @@ export class ClientHttp2Stream extends Duplex {
session[kDenoClientRid],
this.#rid,
);
- const response = await op_http2_client_get_response(
+ const [response, endStream] = await op_http2_client_get_response(
this.#rid,
);
debugHttp2(">>> after get response", response);
@@ -831,7 +831,13 @@ export class ClientHttp2Stream extends Duplex {
...Object.fromEntries(response.headers),
};
debugHttp2(">>> emitting response", headers);
- this.emit("response", headers, 0);
+ this.emit(
+ "response",
+ headers,
+ endStream
+ ? constants.NGHTTP2_FLAG_END_STREAM
+ : constants.NGHTTP2_FLAG_NONE,
+ );
this[kDenoResponse] = response;
this.emit("ready");
})();