Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

append request headers instead of replacing #37845

Merged
merged 1 commit into from Mar 25, 2018
Merged

append request headers instead of replacing #37845

merged 1 commit into from Mar 25, 2018

Conversation

aplc0r
Copy link
Contributor

@aplc0r aplc0r commented Mar 23, 2018

SUMMARY

Request headers are being replaced if any custom headers are supplied. This causes servers to respond with a 415 status code due to the Content-Type header not being sent.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

win_uri

ANSIBLE VERSION
ansible 2.6.0 (devel c29d616f9c) last updated 2018/03/23 15:03:52 (GMT +000)
  config file = None
  configured module search path = [u'/home/vagrant/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vagrant/ansible/lib/ansible
  executable location = /home/vagrant/ansible/bin/ansible
  python version = 2.7.6 (default, Nov 23 2017, 15:49:48) [GCC 4.8.4]
ADDITIONAL INFORMATION

Test task:

    - name: Add Members
      win_uri:
        method: POST
        content_type: 'application/json'
        url: https://anstest.sysqa.com:8888/post-test/members
        validate_certs: no
        headers:
          Cookie: "X_AUTH_TOKEN={{token.content}}"
        body: "{{ member_body | to_json }}" 
        return_content: yes
      with_sequence: count={{ number_of_members }}
      register: member_response

Before:

failed: [anstest.sysqa.com] (item=1) => {
    "accept": "application/octet-stream, text/plain;charset=ISO-8859-1, application/xml, text/xml, application/x-www-form-urlencoded, application/*+xml, multipart/form-data, application/json;charset=UTF-8, application/*+json;charset=UTF-8, */*",
    "cache_control": "no-cache, no-store, max-age=0, must-revalidate",
    "changed": false,
    "character_set": null,
    "connection": "close",
    "content": "",
    "content_encoding": "",
    "content_length": "0",
    "content_type": "",
    "cookies": [],
    "date": "Fri, 23 Mar 2018 15:17:32 GMT",
    "expires": "0",
    "headers": [
        "X-Content-Type-Options",
        "X-XSS-Protection",
        "Pragma",
        "Strict-Transport-Security",
        "X-Frame-Options",
        "Accept",
        "Connection",
        "Content-Length",
        "Cache-Control",
        "Date",
        "Expires"
    ],
    "is_from_cache": false,
    "is_mutually_authenticated": false,
    "item": "1",
    "last_modified": "2018-03-23T10:17:32.2103489-05:00",
    "method": "POST",
    "msg": "Status code of request 'UnsupportedMediaType' is not in list of valid status codes 200.",
    "pragma": "no-cache",
    "protocol_version": {
        "Build": -1,
        "Major": 1,
        "MajorRevision": -1,
        "Minor": 1,
        "MinorRevision": -1,
        "Revision": -1
    },
    "response_uri": "https://anstest.sysqa.com:8888/post-test/members",
    "server": "",
    "status_code": 415,
    "status_description": "",
    "strict_transport_security": "max-age=31536000 ; includeSubDomains",
    "supports_headers": true,
    "url": "https://anstest.sysqa.com:8888/post-test/members",
    "x_content_type_options": "nosniff",
    "x_frame_options": "DENY",
    "xxss_protection": "1; mode=block"
}

After:

ok: [anstest.sysqa.com] => (item=1) => {
    "cache_control": "no-cache, no-store, max-age=0, must-revalidate",
    "changed": false,
    "character_set": "ISO-8859-1",
    "content": "12acaf7c-476e-45fc-89f6-024b7724b02f",
    "content_encoding": "",
    "content_length": "36",
    "content_type": "text/plain;charset=ISO-8859-1",
    "cookies": [],
    "date": "Fri, 23 Mar 2018 15:18:40 GMT",
    "expires": "0",
    "headers": [
        "X-Content-Type-Options",
        "X-XSS-Protection",
        "Pragma",
        "Strict-Transport-Security",
        "X-Frame-Options",
        "Content-Length",
        "Cache-Control",
        "Content-Type",
        "Date",
        "Expires"
    ],
    "is_from_cache": false,
    "is_mutually_authenticated": false,
    "item": "1",
    "last_modified": "2018-03-23T10:18:40.4782029-05:00",
    "method": "POST",
    "pragma": "no-cache",
    "protocol_version": {
        "Build": -1,
        "Major": 1,
        "MajorRevision": -1,
        "Minor": 1,
        "MinorRevision": -1,
        "Revision": -1
    },
    "response_uri": "https://anstest.sysqa.com:8888/post-test/members",
    "server": "",
    "status_code": 200,
    "status_description": "",
    "strict_transport_security": "max-age=31536000 ; includeSubDomains",
    "supports_headers": true,
    "url": "https://anstest.sysqa.com:8888/post-test/members",
    "x_content_type_options": "nosniff",
    "x_frame_options": "DENY",
    "xxss_protection": "1; mode=block"
}

@ansibot
Copy link
Contributor

ansibot commented Mar 23, 2018

@ansibot ansibot added bug This issue/PR relates to a bug. community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. support:community This issue/PR relates to code supported by the Ansible community. test This PR relates to tests. windows Windows community labels Mar 23, 2018
@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Mar 23, 2018
@jborean93 jborean93 merged commit 2c44061 into ansible:devel Mar 25, 2018
jborean93 pushed a commit to jborean93/ansible that referenced this pull request Mar 25, 2018
@jborean93
Copy link
Contributor

Backport PR to stable-2.5 #37889

ryancurrah pushed a commit to ryancurrah/ansible that referenced this pull request Mar 25, 2018
jborean93 added a commit that referenced this pull request Apr 2, 2018
* append request headers instead of replacing (#37845)

(cherry picked from commit 2c44061)

* Added changelog fragment
@ansible ansible locked and limited conversation to collaborators Apr 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. new_contributor This PR is the first contribution by a new community member. support:community This issue/PR relates to code supported by the Ansible community. test This PR relates to tests. windows Windows community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants