MCPcopy Create free account
hub / github.com/bajrangCoder/setu / spawn_request

Method spawn_request

src/http/client.rs:46–62  ·  view source on GitHub ↗

Spawn an HTTP request on the Tokio runtime and return a receiver for the result. This allows GPUI's async executor to await the result without being in a Tokio context.

(
        &self,
        method: HttpMethod,
        url: String,
        headers: Vec<Header>,
        body: RequestBody,
    )

Source from the content-addressed store, hash-verified

44 /// Spawn an HTTP request on the Tokio runtime and return a receiver for the result.
45 /// This allows GPUI's async executor to await the result without being in a Tokio context.
46 pub fn spawn_request(
47 &self,
48 method: HttpMethod,
49 url: String,
50 headers: Vec<Header>,
51 body: RequestBody,
52 ) -> (oneshot::Receiver<Result<ResponseData>>, InFlightRequest) {
53 let (tx, rx) = oneshot::channel();
54 let client = self.client.clone();
55
56 let task = self.runtime.spawn(async move {
57 let result = execute_request(client, method, url, headers, body).await;
58 let _ = tx.send(result);
59 });
60
61 (rx, InFlightRequest { task: Some(task) })
62 }
63}
64
65/// Internal function to execute the HTTP request

Callers 1

send_requestMethod · 0.80

Calls 1

execute_requestFunction · 0.85

Tested by

no test coverage detected