MCPcopy Create free account
hub / github.com/LEXUGE/dcompass / query

Method query

droute/src/router/upstreams/upstream/qhandle/https.rs:147–168  ·  view source on GitHub ↗
(&self, msg: &Message<Bytes>)

Source from the content-addressed store, hash-verified

145#[async_trait]
146impl QHandle for PostClient {
147 async fn query(&self, msg: &Message<Bytes>) -> Result<Message<Bytes>> {
148 // Per RFC, the message ID should be set to 0 to better facilitate HTTPS caching.
149 let mut msg = Message::from_octets(BytesMut::from(msg.as_slice()))?;
150 msg.header_mut().set_id(0);
151
152 let body: reqwest::Body = msg.into_octets().freeze().into();
153 let res = self
154 .0
155 .post(self.1.clone())
156 .header("content-type", "application/dns-message")
157 .body(body)
158 .send()
159 .await?;
160
161 if res.status().is_success() {
162 let res = res.bytes().await?;
163 let answer = Message::from_octets(res)?;
164 Ok(answer)
165 } else {
166 Err(QHandleError::FailedHttp(res.status()))
167 }
168 }
169
170 async fn reusable(&self) -> deadpool::managed::RecycleResult<std::io::Error> {
171 Ok(())

Callers

nothing calls this directly

Calls 1

sendMethod · 0.80

Tested by

no test coverage detected