MCPcopy Create free account
hub / github.com/Louisym/MiniCC / http_response_with_headers

Function http_response_with_headers

rust/crates/api/tests/client_integration.rs:394–409  ·  view source on GitHub ↗
(
    status: &str,
    content_type: &str,
    body: &str,
    headers: &[(&str, &str)],
)

Source from the content-addressed store, hash-verified

392}
393
394fn http_response_with_headers(
395 status: &str,
396 content_type: &str,
397 body: &str,
398 headers: &[(&str, &str)],
399) -> String {
400 let mut extra_headers = String::new();
401 for (name, value) in headers {
402 use std::fmt::Write as _;
403 write!(&mut extra_headers, "{name}: {value}\r\n").expect("header write should succeed");
404 }
405 format!(
406 "HTTP/1.1 {status}\r\ncontent-type: {content_type}\r\n{extra_headers}content-length: {}\r\nconnection: close\r\n\r\n{body}",
407 body.len()
408 )
409}
410
411fn sample_request(stream: bool) -> MessageRequest {
412 MessageRequest {

Callers 1

http_responseFunction · 0.85

Calls 1

expectMethod · 0.80

Tested by

no test coverage detected