Skip to content

Commit

Permalink
append request headers instead of replacing (ansible#37845)
Browse files Browse the repository at this point in the history
  • Loading branch information
aplc0r authored and jborean93 committed Mar 25, 2018
1 parent d502745 commit 2c44061
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ansible/modules/windows/win_uri.ps1
Expand Up @@ -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) {
Expand Down
21 changes: 21 additions & 0 deletions test/integration/targets/win_uri/tasks/test.yml
Expand Up @@ -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'

0 comments on commit 2c44061

Please sign in to comment.