Skip to content

Commit

Permalink
Merge pull request #37 from fermyon/outbound-http-no-perms
Browse files Browse the repository at this point in the history
Change where the HttpRequestDenied is returned
  • Loading branch information
rylev authored Aug 27, 2024
2 parents f00b59c + a5cb0e9 commit 6ec9e9d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions components/outbound-wasi-http-v0.2.0/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,29 @@ impl bindings::Guest for Component {
let response = match outgoing_handler::handle(outgoing_request, None) {
Ok(r) => r,
Err(e) => {
return_response(outparam, 500, e.to_string().as_bytes());
return_response(
outparam,
500,
format!("outgoing-handler/handle: {e}").as_bytes(),
);
return;
}
};

let response = loop {
if let Some(response) = response.get() {
break response.unwrap().unwrap();
let response = response.unwrap();
match response {
Ok(r) => break r,
Err(e) => {
return_response(
outparam,
500,
format!("incoming-response#get: {e}").as_bytes(),
);
return;
}
};
} else {
response.subscribe().block()
}
Expand Down
2 changes: 1 addition & 1 deletion tests/outbound-wasi-http-v0.2.0-no-perms/test.json5
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"optional": true
}
],
"body": "ErrorCode::HttpRequestDenied"
"body": "incoming-response#get: ErrorCode::HttpRequestDenied"
},
}
],
Expand Down

0 comments on commit 6ec9e9d

Please sign in to comment.