MCPcopy Create free account
hub / github.com/bajrangCoder/setu / classify_content

Method classify_content

src/entities/response.rs:285–322  ·  view source on GitHub ↗
(content_type: Option<&str>, body_bytes: &[u8])

Source from the content-addressed store, hash-verified

283
284 if std::str::from_utf8(sample).is_ok() {
285 return true;
286 }
287
288 let printable = sample
289 .iter()
290 .filter(|&&b| b == b'\n' || b == b'\r' || b == b'\t' || (0x20..=0x7E).contains(&b))
291 .count();
292
293 printable * 100 / sample_len >= 90
294 }
295
296 /// Create a new ResponseData with computed hash
297 pub fn new(
298 status_code: u16,
299 status_text: String,
300 headers: HashMap<String, String>,
301 body: String,
302 body_bytes: Vec<u8>,
303 body_size_bytes: usize,
304 duration_ms: u64,
305 content_type: Option<String>,
306 ) -> Self {
307 let mut response = Self {
308 status_code,
309 status_text,
310 headers,
311 request_headers: HashMap::new(),
312 request_url: String::new(),
313 payload: ResponsePayload {
314 body: Arc::from(body),
315 body_bytes: Bytes::from(body_bytes),
316 ..ResponsePayload::default()
317 },
318 body_size_bytes,
319 duration_ms,
320 content_type,
321 };
322 response.compact_storage();
323 response
324 }
325

Callers

nothing calls this directly

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected