mirror of
https://github.com/nushell/nushell
synced 2024-12-27 21:43:09 +00:00
Avoid duplicating post headers (#5200)
* Avoid duplicating post headers This should fix #5194 * Update post.rs Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
This commit is contained in:
parent
6a1378c1bb
commit
8e2847431e
1 changed files with 7 additions and 3 deletions
|
@ -205,6 +205,13 @@ fn helper(
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut request = http_client(args.insecure.is_some()).post(location);
|
let mut request = http_client(args.insecure.is_some()).post(location);
|
||||||
|
|
||||||
|
// set the content-type header before using e.g., request.json
|
||||||
|
// because that will avoid duplicating the header value
|
||||||
|
if let Some(val) = args.content_type {
|
||||||
|
request = request.header("Content-Type", val);
|
||||||
|
}
|
||||||
|
|
||||||
match body {
|
match body {
|
||||||
Value::Binary { val, .. } => {
|
Value::Binary { val, .. } => {
|
||||||
request = request.body(val);
|
request = request.body(val);
|
||||||
|
@ -235,9 +242,6 @@ fn helper(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(val) = args.content_type {
|
|
||||||
request = request.header("Content-Type", val);
|
|
||||||
}
|
|
||||||
if let Some(val) = args.content_length {
|
if let Some(val) = args.content_length {
|
||||||
request = request.header("Content-Length", val);
|
request = request.header("Content-Length", val);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue