win_uri: backport fix custom header override (#37889)

* append request headers instead of replacing (#37845)

(cherry picked from commit 2c44061a04)

* Added changelog fragment
pull/38238/head
Jordan Borean 7 years ago committed by GitHub
parent 0c88f199ec
commit 886a88a967
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,3 @@
bugfixes:
- win_uri - do not override existing header when using the ``headers`` key.
https://github.com/ansible/ansible/pull/37845

@ -125,7 +125,7 @@ if ($headers) {
default { $req_headers.Add($header.Name, $header.Value) }
}
}
$client.Headers = $req_headers
$client.Headers.Add($req_headers)
}
if ($client_cert) {

@ -338,3 +338,24 @@
- invalid_path.content is defined
- invalid_path.method == 'GET'
- invalid_path.connection is defined
- name: post request with custom headers
win_uri:
url: http://{{httpbin_host}}/post
method: POST
headers:
Test-Header: hello
Another-Header: world
content_type: application/json
body: '{"foo": "bar"}'
return_content: yes
register: post_request_with_custom_headers
- name: assert post with custom headers
assert:
that:
- not post_request_with_custom_headers.changed
- post_request_with_custom_headers.status_code == 200
- post_request_with_custom_headers.json.headers['Content-Type'] == "application/json"
- post_request_with_custom_headers.json.headers['Test-Header'] == 'hello'
- post_request_with_custom_headers.json.headers['Another-Header'] == 'world'

Loading…
Cancel
Save