mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
cli: fix delegated http requests not working (#192620)
From a refactor last literation. I don't think this is candidate worthy as it's an uncommon path with remote-tunnels, and we can just toggle this off for remote-ssh for this iteration.
This commit is contained in:
@@ -278,8 +278,8 @@ fn make_socket_rpc(
|
|||||||
port_forwarding: Option<PortForwarding>,
|
port_forwarding: Option<PortForwarding>,
|
||||||
requires_auth: AuthRequired,
|
requires_auth: AuthRequired,
|
||||||
platform: Platform,
|
platform: Platform,
|
||||||
|
http_requests: HttpRequestsMap,
|
||||||
) -> RpcDispatcher<MsgPackSerializer, HandlerContext> {
|
) -> RpcDispatcher<MsgPackSerializer, HandlerContext> {
|
||||||
let http_requests = Arc::new(std::sync::Mutex::new(HashMap::new()));
|
|
||||||
let server_bridges = ServerMultiplexer::new();
|
let server_bridges = ServerMultiplexer::new();
|
||||||
let mut rpc = RpcBuilder::new(MsgPackSerializer {}).methods(HandlerContext {
|
let mut rpc = RpcBuilder::new(MsgPackSerializer {}).methods(HandlerContext {
|
||||||
did_update: Arc::new(AtomicBool::new(false)),
|
did_update: Arc::new(AtomicBool::new(false)),
|
||||||
@@ -377,7 +377,10 @@ fn make_socket_rpc(
|
|||||||
);
|
);
|
||||||
rpc.register_sync("httpheaders", |p: HttpHeadersParams, c| {
|
rpc.register_sync("httpheaders", |p: HttpHeadersParams, c| {
|
||||||
if let Some(req) = c.http_requests.lock().unwrap().get(&p.req_id) {
|
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);
|
req.initial_response(p.status_code, p.headers);
|
||||||
|
} else {
|
||||||
|
warning!(c.log, "got response for unknown req {}", p.req_id);
|
||||||
}
|
}
|
||||||
Ok(EmptyObject {})
|
Ok(EmptyObject {})
|
||||||
});
|
});
|
||||||
@@ -388,6 +391,7 @@ fn make_socket_rpc(
|
|||||||
req.body(p.segment);
|
req.body(p.segment);
|
||||||
}
|
}
|
||||||
if p.complete {
|
if p.complete {
|
||||||
|
trace!(c.log, "delegated request {} completed", p.req_id);
|
||||||
reqs.remove(&p.req_id);
|
reqs.remove(&p.req_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -441,6 +445,7 @@ async fn process_socket(
|
|||||||
port_forwarding,
|
port_forwarding,
|
||||||
requires_auth,
|
requires_auth,
|
||||||
platform,
|
platform,
|
||||||
|
http_requests.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -497,6 +502,7 @@ async fn process_socket(
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
http_requests.lock().unwrap().insert(id, r);
|
http_requests.lock().unwrap().insert(id, r);
|
||||||
|
|
||||||
tx_counter += serialized.len();
|
tx_counter += serialized.len();
|
||||||
|
|||||||
Reference in New Issue
Block a user