use axum::body::{boxed, Body};
use axum::http::header::HeaderName;
use axum::http::HeaderValue;
use axum::response::Response;
use std::str::FromStr;
pub fn cgi_to_response(buffer: &[u8]) -> Response {
let mut headers = [httparse::EMPTY_HEADER; 10];
let (body_offset, headers) = httparse::parse_headers(buffer, &mut headers)
.unwrap()
.unwrap();
let mut response = Response::new(boxed(Body::from(buffer[body_offset..].to_vec())));
for header in headers {
response.headers_mut().insert(
HeaderName::from_str(header.name).unwrap(),
HeaderValue::from_bytes(header.value).unwrap(),
);
}
response
}