MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / proxy_to_backend_streaming

Function proxy_to_backend_streaming

crates/openshell-router/src/backend.rs:728–746  ·  view source on GitHub ↗

Forward a raw HTTP request to the backend, returning response headers immediately without buffering the body. The caller streams the body incrementally via [`StreamingProxyResponse::response`] using `chunk().await`.

(
    client: &reqwest::Client,
    route: &ResolvedRoute,
    _source_protocol: &str,
    method: &str,
    path: &str,
    headers: Vec<(String, String)>,
    body: bytes::Bytes,
)

Source from the content-addressed store, hash-verified

726/// The caller streams the body incrementally via
727/// [`StreamingProxyResponse::response`] using `chunk().await`.
728pub async fn proxy_to_backend_streaming(
729 client: &reqwest::Client,
730 route: &ResolvedRoute,
731 _source_protocol: &str,
732 method: &str,
733 path: &str,
734 headers: Vec<(String, String)>,
735 body: bytes::Bytes,
736) -> Result<StreamingProxyResponse, RouterError> {
737 let response =
738 send_backend_request_streaming(client, route, method, path, &headers, body).await?;
739 let (status, resp_headers) = extract_response_metadata(&response);
740
741 Ok(StreamingProxyResponse {
742 status,
743 headers: resp_headers,
744 body: StreamingBody::Live(response),
745 })
746}
747
748/// Build the upstream URL for a provider route.
749///

Callers 1

Calls 2

Tested by

no test coverage detected