0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-08 07:16:56 -05:00

chore(ext/http): custom arity (#14200)

This commit is contained in:
Divy Srivastava 2022-04-04 15:19:35 +05:30 committed by GitHub
parent 6bb555b549
commit cc49b5e0d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 15 deletions

View file

@ -239,7 +239,9 @@
try { try {
await core.opAsync( await core.opAsync(
"op_http_write_headers", "op_http_write_headers",
[streamRid, innerResp.status ?? 200, innerResp.headerList], streamRid,
innerResp.status ?? 200,
innerResp.headerList,
isStreamingResponseBody ? null : respBody, isStreamingResponseBody ? null : respBody,
); );
} catch (error) { } catch (error) {

View file

@ -43,7 +43,6 @@ use hyper::service::Service;
use hyper::Body; use hyper::Body;
use hyper::Request; use hyper::Request;
use hyper::Response; use hyper::Response;
use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use std::borrow::Cow; use std::borrow::Cow;
use std::cell::RefCell; use std::cell::RefCell;
@ -481,24 +480,14 @@ fn req_headers(
headers headers
} }
// We use a tuple instead of struct to avoid serialization overhead of the keys.
#[derive(Deserialize)]
struct RespondArgs(
// rid:
u32,
// status:
u16,
// headers:
Vec<(ByteString, ByteString)>,
);
#[op] #[op]
async fn op_http_write_headers( async fn op_http_write_headers(
state: Rc<RefCell<OpState>>, state: Rc<RefCell<OpState>>,
args: RespondArgs, rid: u32,
status: u16,
headers: Vec<(ByteString, ByteString)>,
data: Option<StringOrBuffer>, data: Option<StringOrBuffer>,
) -> Result<(), AnyError> { ) -> Result<(), AnyError> {
let RespondArgs(rid, status, headers) = args;
let stream = state let stream = state
.borrow_mut() .borrow_mut()
.resource_table .resource_table