summaryrefslogtreecommitdiff
path: root/ext/node/ops/http.rs
diff options
context:
space:
mode:
authorLeo Kettmeir <crowlkats@toaxl.com>2023-05-27 15:42:20 +0200
committerGitHub <noreply@github.com>2023-05-27 15:42:20 +0200
commitbe59e93220e24a2e66ae2843a136e61eab9d8ac3 (patch)
tree9c49d56516d1f126234d4e11e276750c6028b42a /ext/node/ops/http.rs
parentd0c5ff42f4b5fa9b848e6ed5af2e480d12f15bda (diff)
refactor(node/http): don't use readablestream for writing to request (#19282)
Refactors the internal usage of a readablestream to write to the resource directly --------- Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'ext/node/ops/http.rs')
-rw-r--r--ext/node/ops/http.rs12
1 files changed, 10 insertions, 2 deletions
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<P>(
state: &mut OpState,
method: ByteString,
url: String,
headers: Vec<(ByteString, ByteString)>,
client_rid: Option<u32>,
has_body: bool,
-) -> Result<FetchReturn, AnyError> {
+) -> Result<FetchReturn, AnyError>
+where
+ P: crate::NodePermissions + 'static,
+{
let client = if let Some(rid) = client_rid {
let r = state.resource_table.get::<HttpClientResource>(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::<P>();
+ permissions.check_net_url(&url, "ClientRequest")?;
+ }
+
let mut header_map = HeaderMap::new();
for (key, value) in headers {
let name = HeaderName::from_bytes(&key)