Skip to content

Commit

Permalink
trim content-type value (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilShahi authored Mar 16, 2023
1 parent cd76240 commit 03d5b76
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ingestors/rust-common/src/open_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ fn get_spec_content_type_schema<'a>(
trace_content_type: &str,
spec_status_code_map: &'a HashMap<String, CompiledSchema>,
) -> Result<Option<&'a CompiledSchema>, String> {
let content_type = match trace_content_type.parse::<mime::Mime>() {
if trace_content_type.trim().is_empty() {
return Err("No Content-Type is used for the response body.".to_owned());
}
let content_type = match trace_content_type.trim().parse::<mime::Mime>() {
Ok(m) => m.essence_str().to_owned(),
Err(_) => {
return Err(format!(
Expand Down
4 changes: 3 additions & 1 deletion ingestors/rust-common/src/process_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ fn get_content_type(headers: &[KeyVal]) -> Option<&String> {
}

fn get_mime_type(content_type_header: Option<&String>) -> mime::Mime {
content_type_header.map_or(mime::TEXT_PLAIN, |e| e.parse().unwrap_or(mime::TEXT_PLAIN))
content_type_header.map_or(mime::TEXT_PLAIN, |e| {
e.trim().parse().unwrap_or(mime::TEXT_PLAIN)
})
}

fn combine_process_trace_res(
Expand Down

0 comments on commit 03d5b76

Please sign in to comment.