fix: default content type
This commit is contained in:
parent
63b83e77dc
commit
30468e378d
|
|
@ -300,14 +300,19 @@ fn run_check_blocking(
|
||||||
.method(method)
|
.method(method)
|
||||||
.uri(url);
|
.uri(url);
|
||||||
|
|
||||||
|
let mut has_content_type = false;
|
||||||
if let Some(hdrs) = headers {
|
if let Some(hdrs) = headers {
|
||||||
for (k, v) in hdrs {
|
for (k, v) in hdrs {
|
||||||
|
if k.eq_ignore_ascii_case("content-type") { has_content_type = true; }
|
||||||
builder = builder.header(k.as_str(), v.as_str());
|
builder = builder.header(k.as_str(), v.as_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = match body {
|
let result = match body {
|
||||||
Some(b) => {
|
Some(b) => {
|
||||||
|
if !has_content_type {
|
||||||
|
builder = builder.header("Content-Type", "application/json");
|
||||||
|
}
|
||||||
let req = builder.body(b.as_bytes()).map_err(|e| e.to_string())?;
|
let req = builder.body(b.as_bytes()).map_err(|e| e.to_string())?;
|
||||||
agent.run(req)
|
agent.run(req)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue