From be59e93220e24a2e66ae2843a136e61eab9d8ac3 Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Sat, 27 May 2023 15:42:20 +0200 Subject: refactor(node/http): don't use readablestream for writing to request (#19282) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactors the internal usage of a readablestream to write to the resource directly --------- Co-authored-by: Bartek IwaƄczuk --- ext/node/ops/http.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'ext/node/ops') diff --git a/ext/node/ops/http.rs b/ext/node/ops/http.rs index 2039fb388..cc7dbf522 100644 --- a/ext/node/ops/http.rs +++ b/ext/node/ops/http.rs @@ -24,14 +24,17 @@ use reqwest::Body; use reqwest::Method; #[op] -pub fn op_node_http_request( +pub fn op_node_http_request

( state: &mut OpState, method: ByteString, url: String, headers: Vec<(ByteString, ByteString)>, client_rid: Option, has_body: bool, -) -> Result { +) -> Result +where + P: crate::NodePermissions + 'static, +{ let client = if let Some(rid) = client_rid { let r = state.resource_table.get::(rid)?; r.client.clone() @@ -42,6 +45,11 @@ pub fn op_node_http_request( let method = Method::from_bytes(&method)?; let url = Url::parse(&url)?; + { + let permissions = state.borrow_mut::

(); + permissions.check_net_url(&url, "ClientRequest")?; + } + let mut header_map = HeaderMap::new(); for (key, value) in headers { let name = HeaderName::from_bytes(&key) -- cgit v1.2.3