mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 19:20:22 -07:00
* Issue #19575: Adding Dest Param to win_uri Added `dest` param to win_uri. Outputs the response body to a specified file. Addresses Issue #19575 * Was setting the wrong attribute
This commit is contained in:
parent
b7780ca530
commit
9b7c9931db
2 changed files with 11 additions and 0 deletions
|
@ -42,6 +42,7 @@ $method = Get-AnsibleParam -obj $params "method" -default "GET"
|
||||||
$content_type = Get-AnsibleParam -obj $params -name "content_type"
|
$content_type = Get-AnsibleParam -obj $params -name "content_type"
|
||||||
$headers = Get-AnsibleParam -obj $params -name "headers"
|
$headers = Get-AnsibleParam -obj $params -name "headers"
|
||||||
$body = Get-AnsibleParam -obj $params -name "body"
|
$body = Get-AnsibleParam -obj $params -name "body"
|
||||||
|
$dest = Get-AnsibleParam -obj $params -name "dest" -default $null
|
||||||
$use_basic_parsing = ConvertTo-Bool (Get-AnsibleParam -obj $params -name "use_basic_parsing" -default $true)
|
$use_basic_parsing = ConvertTo-Bool (Get-AnsibleParam -obj $params -name "use_basic_parsing" -default $true)
|
||||||
|
|
||||||
$webrequest_opts.Uri = $url
|
$webrequest_opts.Uri = $url
|
||||||
|
@ -70,6 +71,11 @@ if ($body -ne $null) {
|
||||||
Set-Attr $result.win_uri "body" $body
|
Set-Attr $result.win_uri "body" $body
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($dest -ne $null) {
|
||||||
|
$webrequest_opts.OutFile = $dest
|
||||||
|
Set-Attr $result.win_uri "dest" $dest
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$response = Invoke-WebRequest @webrequest_opts
|
$response = Invoke-WebRequest @webrequest_opts
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
@ -57,6 +57,11 @@ options:
|
||||||
body:
|
body:
|
||||||
description:
|
description:
|
||||||
- The body of the HTTP request/response to the web service.
|
- The body of the HTTP request/response to the web service.
|
||||||
|
dest:
|
||||||
|
version_added: "2.3"
|
||||||
|
description:
|
||||||
|
- Output the response body to a file.
|
||||||
|
default: None
|
||||||
headers:
|
headers:
|
||||||
description:
|
description:
|
||||||
- 'Key Value pairs for headers. Example "Host: www.somesite.com"'
|
- 'Key Value pairs for headers. Example "Host: www.somesite.com"'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue