MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / convert_request

Function convert_request

crates/bindings/src/http.rs:548–590  ·  view source on GitHub ↗
(parts: http::request::Parts)

Source from the content-addressed store, hash-verified

546}
547
548fn convert_request(parts: http::request::Parts) -> st_http::Request {
549 let http::request::Parts {
550 method,
551 uri,
552 version,
553 headers,
554 mut extensions,
555 ..
556 } = parts;
557
558 let timeout = extensions.remove::<Timeout>();
559 if !extensions.is_empty() {
560 log::warn!("Converting HTTP `Request` with unrecognized extensions");
561 }
562 st_http::Request {
563 method: match method {
564 http::Method::GET => st_http::Method::Get,
565 http::Method::HEAD => st_http::Method::Head,
566 http::Method::POST => st_http::Method::Post,
567 http::Method::PUT => st_http::Method::Put,
568 http::Method::DELETE => st_http::Method::Delete,
569 http::Method::CONNECT => st_http::Method::Connect,
570 http::Method::OPTIONS => st_http::Method::Options,
571 http::Method::TRACE => st_http::Method::Trace,
572 http::Method::PATCH => st_http::Method::Patch,
573 _ => st_http::Method::Extension(method.to_string()),
574 },
575 headers: headers
576 .into_iter()
577 .map(|(k, v)| (k.map(|k| k.as_str().into()), v.as_bytes().into()))
578 .collect(),
579 timeout: timeout.map(Into::into),
580 uri: uri.to_string(),
581 version: match version {
582 http::Version::HTTP_09 => st_http::Version::Http09,
583 http::Version::HTTP_10 => st_http::Version::Http10,
584 http::Version::HTTP_11 => st_http::Version::Http11,
585 http::Version::HTTP_2 => st_http::Version::Http2,
586 http::Version::HTTP_3 => st_http::Version::Http3,
587 _ => unreachable!("Unknown HTTP version: {version:?}"),
588 },
589 }
590}
591
592fn convert_response(response: st_http::Response) -> http::Result<http::response::Parts> {
593 let st_http::Response { headers, version, code } = response;

Callers 1

sendMethod · 0.85

Calls 7

is_emptyMethod · 0.45
to_stringMethod · 0.45
collectMethod · 0.45
mapMethod · 0.45
into_iterMethod · 0.45
as_strMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…