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

win_uri: stop output from mixing with module result #48140

Merged
merged 1 commit into from Nov 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/win_uri-junk-data.yaml
@@ -0,0 +1,2 @@
bugfixes:
- win_uri - stop junk output from being returned to Ansible - https://github.com/ansible/ansible/issues/47998
6 changes: 3 additions & 3 deletions lib/ansible/modules/windows/win_uri.ps1
Expand Up @@ -239,7 +239,7 @@ if ($return_content -or $dest) {
$resp_st.Close()

if ($return_content) {
$memory_st.Seek(0, [System.IO.SeekOrigin]::Begin)
$memory_st.Seek(0, [System.IO.SeekOrigin]::Begin) > $null
$content_bytes = $memory_st.ToArray()
$result.content = [System.Text.Encoding]::UTF8.GetString($content_bytes)
if ($result.ContainsKey("content_type") -and $result.content_type -Match ($JSON_CANDIDATES -join '|')) {
Expand All @@ -252,7 +252,7 @@ if ($return_content -or $dest) {
}

if ($dest) {
$memory_st.Seek(0, [System.IO.SeekOrigin]::Begin)
$memory_st.Seek(0, [System.IO.SeekOrigin]::Begin) > $null
$changed = $true

if (Test-AnsiblePath -Path $dest) {
Expand All @@ -268,7 +268,7 @@ if ($return_content -or $dest) {

$result.changed = $changed
if ($changed -and (-not $check_mode)) {
$memory_st.Seek(0, [System.IO.SeekOrigin]::Begin)
$memory_st.Seek(0, [System.IO.SeekOrigin]::Begin) > $null
$file_stream = [System.IO.File]::Create($dest)
try {
$memory_st.CopyTo($file_stream)
Expand Down