MCPcopy Create free account
hub / github.com/PerroEngine/Perro / send_request

Function send_request

perro_source/api_modules/perro_networking/src/http.rs:517–601  ·  view source on GitHub ↗
(
    agent: &ureq::Agent,
    config: &HttpConfig,
    id: HttpID,
    request: HttpRequest,
)

Source from the content-addressed store, hash-verified

515 HttpMethod::Patch,
516 url,
517 HttpBody::Variant(body),
518 ))
519 }
520
521 pub fn post_bytes(&mut self, url: impl Into<String>, body: Vec<u8>) -> HttpID {
522 self.request(HttpRequest::post_bytes(url, body))
523 }
524
525 pub fn poll(&mut self) -> Option<HttpEvent> {
526 if let Some(event) = self.local_events.pop_front() {
527 return Some(event);
528 }
529 self.rx.try_recv().ok()
530 }
531
532 pub fn poll_all(&mut self, max_events: usize) -> Vec<HttpEvent> {
533 let mut out = Vec::new();
534 for _ in 0..max_events {
535 let Some(event) = self.poll() else {
536 break;
537 };
538 out.push(event);
539 }
540 out
541 }
542
543 pub fn config(&self) -> &HttpConfig {
544 &self.config
545 }
546
547 pub fn queue_config(&self) -> HttpQueueConfig {
548 self.queue_config
549 }
550
551 pub fn rejected_requests(&self) -> u64 {
552 self.rejected_requests
553 }
554
555 fn next_http_id(&mut self) -> HttpID {
556 let id = HttpID(self.next_id);
557 self.next_id = self.next_id.wrapping_add(1);
558 id
559 }
560}
561
562impl Default for HttpClient {
563 fn default() -> Self {
564 Self::new()
565 }
566}
567
568fn http_worker(
569 config: HttpConfig,
570 work_rx: Arc<Mutex<Receiver<HttpWork>>>,
571 event_tx: SyncSender<HttpEvent>,
572 shared_agent: Option<ureq::Agent>,
573) {
574 loop {

Callers 1

run_http_workFunction · 0.85

Calls 15

apply_headersFunction · 0.85
encode_bodyFunction · 0.85
map_ureq_errorFunction · 0.85
response_headersFunction · 0.85
map_read_errorFunction · 0.85
cloneMethod · 0.80
buildMethod · 0.80
configMethod · 0.80
sendMethod · 0.80
patchMethod · 0.80
as_u16Method · 0.80
limitMethod · 0.80

Tested by

no test coverage detected