win_uri: fixes (#35487)

* win_uri: moved away from Invoke-WebRequest and fixed multiple issues

* fixes from review
This commit is contained in:
Jordan Borean 2018-02-07 20:58:47 +11:00 committed by GitHub
parent 63fdc3f08f
commit a0178b79f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 528 additions and 134 deletions

View file

@ -22,12 +22,11 @@ options:
url:
description:
- Supports FTP, HTTP or HTTPS URLs in the form of (ftp|http|https)://host.domain:port/path.
- Also supports file:/// URLs through Invoke-WebRequest.
required: yes
method:
description:
- The HTTP Method of the request or response.
choices: [ CONNECT, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, REFRESH, TRACE ]
choices: [ CONNECT, DELETE, GET, HEAD, MERGE, OPTIONS, PATCH, POST, PUT, REFRESH, TRACE ]
default: GET
content_type:
description:
@ -43,16 +42,30 @@ options:
description:
- Password to use for authentication.
version_added: '2.4'
force_basic_auth:
description:
- By default the authentication information is only sent when a webservice
responds to an initial request with a 401 status. Since some basic auth
services do not properly send a 401, logins will fail.
- This option forces the sending of the Basic authentication header upon
the initial request.
type: bool
default: 'no'
version_added: '2.5'
dest:
description:
- Output the response body to a file.
version_added: '2.3'
headers:
description:
- 'Key Value pairs for headers. Example "Host: www.somesite.com"'
- Extra headers to set on the request, see the examples for more details on
how to set this.
use_basic_parsing:
description:
- This module relies upon 'Invoke-WebRequest', which by default uses the Internet Explorer Engine to parse a webpage.
- As of Ansible 2.5, this option is no longer valid and cannot be changed from C(yes), this option will be removed
in Ansible 2.7.
- Before Ansible 2.5, this module relies upon 'Invoke-WebRequest', which by default uses the Internet Explorer Engine
to parse a webpage.
- There's an edge-case where if a user hasn't run IE before, this will fail.
- The only advantage to using the Internet Explorer praser is that you can traverse the DOM in a powershell script.
- That isn't useful for Ansible, so by default we toggle 'UseBasicParsing'. However, you can toggle that off here.
@ -120,8 +133,17 @@ options:
version_added: '2.4'
client_cert:
description:
- Specifies the client certificate(.pfx) that is used for a secure web request.
- Specifies the client certificate (.pfx) that is used for a secure web request.
- The WinRM connection must be authenticated with C(CredSSP) if the
certificate file is not password protected.
- Other authentication types can set I(client_cert_password) when the cert
is password protected.
version_added: '2.4'
client_cert_password:
description:
- The password for the client certificate (.pfx) file that is used for a
secure web request.
version_added: '2.5'
notes:
- For non-Windows targets, use the M(uri) module instead.
author:
@ -161,26 +183,6 @@ url:
returned: always
type: string
sample: https://www.ansible.com
method:
description: The HTTP method used.
returned: always
type: string
sample: GET
content_type:
description: The "content-type" header used.
returned: always
type: string
sample: application/json
use_basic_parsing:
description: The state of the "use_basic_parsing" flag.
returned: always
type: bool
sample: True
body:
description: The content of the body used
returned: when body is specified
type: string
sample: '{"id":1}'
status_code:
description: The HTTP Status Code of the response.
returned: success
@ -191,19 +193,19 @@ status_description:
returned: success
type: string
sample: OK
raw_content:
content:
description: The raw content of the HTTP response.
returned: success
returned: success and return_content is True
type: string
sample: 'HTTP/1.1 200 OK\nX-XSS-Protection: 1; mode=block\nAlternate-Protocol: 443:quic,p=1\nAlt-Svc: quic="www.google.com:443";'
headers:
description: The Headers of the response.
returned: success
type: dict
sample: {"Content-Type": "application/json"}
raw_content_length:
sample: '{"foo": "bar"}'
content_length:
description: The byte size of the response.
returned: success
type: int
sample: 54447
json:
description: The json structure returned under content as a dictionary
returned: success and Content-Type is "application/json" or "application/javascript" and return_content is True
type: dict
sample: {"this-is-dependent": "on the actual return content"}
'''