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

Method get_all_headers

src/views/request_view.rs:362–406  ·  view source on GitHub ↗

Get all headers including auth headers

(&self, cx: &App)

Source from the content-addressed store, hash-verified

360 };
361 let content = self
362 .get_body_content(cx)
363 .or_else(|| stored_text_body.clone())
364 .unwrap_or_default();
365
366 match self.body_type {
367 BodyType::None => RequestBody::None,
368 BodyType::Json => RequestBody::Json(content),
369 BodyType::Text | BodyType::Html | BodyType::Xml => RequestBody::Text(content),
370 BodyType::FormUrlEncoded => {
371 if let Some(ref editor) = self.form_data_editor {
372 RequestBody::FormData(editor.read(cx).get_form_data(cx))
373 } else if let RequestBody::FormData(data) = stored_body {
374 RequestBody::FormData(data)
375 } else {
376 RequestBody::FormData(std::collections::HashMap::new())
377 }
378 }
379 BodyType::FormData => {
380 if let Some(ref editor) = self.multipart_form_data_editor {
381 RequestBody::MultipartFormData(editor.read(cx).get_multipart_fields(cx))
382 } else if let RequestBody::MultipartFormData(fields) = stored_body {
383 RequestBody::MultipartFormData(fields)
384 } else {
385 RequestBody::MultipartFormData(Vec::new())
386 }
387 }
388 }
389 }
390
391 /// Get all headers including auth headers
392 pub fn get_all_headers(&self, cx: &App) -> Vec<Header> {
393 let mut headers = if let Some(ref editor) = self.header_editor {
394 editor.read(cx).get_headers(cx)
395 } else {
396 self.request.read(cx).headers().to_vec()
397 };
398
399 // Add Content-Type header based on body type
400 // Skip for FormData (multipart) - reqwest sets this automatically with boundary
401 if self.body_type != BodyType::FormData
402 && let Some(content_type) = self.body_type.content_type()
403 {
404 if let Some(header) = headers
405 .iter_mut()
406 .find(|header| header.key.eq_ignore_ascii_case("Content-Type"))
407 {
408 // Don't clobber a user-supplied custom MIME type
409 // (e.g. application/vnd.api+json, text/csv).

Callers 1

Calls 5

get_headersMethod · 0.80
headersMethod · 0.80
content_typeMethod · 0.80
get_configMethod · 0.80
to_headerMethod · 0.80

Tested by

no test coverage detected