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

Function proxy_to_backend

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

Forward a raw HTTP request to the backend configured in `route`. Buffers the entire response body before returning. Suitable for non-streaming responses or mock routes.

(
    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

658/// Buffers the entire response body before returning. Suitable for
659/// non-streaming responses or mock routes.
660pub async fn proxy_to_backend(
661 client: &reqwest::Client,
662 route: &ResolvedRoute,
663 _source_protocol: &str,
664 method: &str,
665 path: &str,
666 headers: Vec<(String, String)>,
667 body: bytes::Bytes,
668) -> Result<ProxyResponse, RouterError> {
669 let response = send_backend_request(client, route, method, path, &headers, body).await?;
670 let (status, resp_headers) = extract_response_metadata(&response);
671 let body = read_capped_response_body(response, MAX_BUFFERED_RESPONSE_BODY).await?;
672
673 Ok(ProxyResponse {
674 status,
675 headers: resp_headers,
676 body,
677 })
678}
679
680/// Read a response body fully into memory, rejecting anything over `max` bytes.
681///

Calls 3

send_backend_requestFunction · 0.85

Tested by

no test coverage detected