Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: fix delegated http requests not working #192620

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion cli/src/tunnels/control_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ fn make_socket_rpc(
port_forwarding: Option<PortForwarding>,
requires_auth: AuthRequired,
platform: Platform,
http_requests: HttpRequestsMap,
) -> RpcDispatcher<MsgPackSerializer, HandlerContext> {
let http_requests = Arc::new(std::sync::Mutex::new(HashMap::new()));
let server_bridges = ServerMultiplexer::new();
let mut rpc = RpcBuilder::new(MsgPackSerializer {}).methods(HandlerContext {
did_update: Arc::new(AtomicBool::new(false)),
Expand Down Expand Up @@ -377,7 +377,10 @@ fn make_socket_rpc(
);
rpc.register_sync("httpheaders", |p: HttpHeadersParams, c| {
if let Some(req) = c.http_requests.lock().unwrap().get(&p.req_id) {
trace!(c.log, "got {} response for req {}", p.status_code, p.req_id);
req.initial_response(p.status_code, p.headers);
} else {
warning!(c.log, "got response for unknown req {}", p.req_id);
}
Ok(EmptyObject {})
});
Expand All @@ -388,6 +391,7 @@ fn make_socket_rpc(
req.body(p.segment);
}
if p.complete {
trace!(c.log, "delegated request {} completed", p.req_id);
reqs.remove(&p.req_id);
}
}
Expand Down Expand Up @@ -441,6 +445,7 @@ async fn process_socket(
port_forwarding,
requires_auth,
platform,
http_requests.clone(),
);

{
Expand Down Expand Up @@ -497,6 +502,7 @@ async fn process_socket(
}),
})
.unwrap();

http_requests.lock().unwrap().insert(id, r);

tx_counter += serialized.len();
Expand Down