Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add OutFile property in WebResponseObject#24047

Merged
daxian-dbw merged 5 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
jshigetomi:issue-21082-fixjshigetomi/PowerShell:issue-21082-fixCopy head branch name to clipboard
Jul 23, 2024
Merged

Add OutFile property in WebResponseObject#24047
daxian-dbw merged 5 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
jshigetomi:issue-21082-fixjshigetomi/PowerShell:issue-21082-fixCopy head branch name to clipboard

Conversation

@jshigetomi

@jshigetomi jshigetomi commented Jul 12, 2024

Copy link
Copy Markdown
Collaborator

PR Summary

Fixes: #21082

Added OutFile as a property in WebResponseObject. OutFile will save whenever writing to pipe line.
Refactored one line to reduce redundancy.

PR Context

PR extends WebObjectResponse with a property that stores the installed file's path. It makes sense to have this as a built in property since we have access to it.

PR Checklist

@jshigetomi jshigetomi changed the title Issue 21082 fix Fix Invoke-WeRequest -PassThru -OutFile WebRequestObject Property .OutFile Stores Out File Path Jul 12, 2024

@iSazonov iSazonov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests for the scenario in WebCmdlets.Tests.ps1.

…ll now be saved to the WebResponseObject when -OutFile flag is used. Added Tests for directory, file, and verbose.

Co-authored-by: Ilya <darpa@yandex.ru>
@iSazonov

Copy link
Copy Markdown
Collaborator

@mklement0 Please review.

/// <summary>
/// Gets or sets the output file path.
/// </summary>
public string? OutFile { get; set; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be an internal set?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree (public string? OutFile { get; internal set; })

@SteveL-MSFT, @iSazonov, just to confirm: Is it generally fine to extend public classes with new members?

Other than that, LGTM - thanks for taking this on, @jshigetomi.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mklement0 Removing public element is a breaking change, adding is ok.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jshigetomi Please address the request.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iSazonov Thank you for bringing this to my attention. I misread this chain and thought there were no actionable items.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Jul 16, 2024
@iSazonov iSazonov changed the title Fix Invoke-WeRequest -PassThru -OutFile WebRequestObject Property .OutFile Stores Out File Path Add OutFile property in WebResponseObject Jul 17, 2024
@iSazonov

Copy link
Copy Markdown
Collaborator

@jshigetomi Please resolve merge conflicts.

@microsoft-github-policy-service microsoft-github-policy-service Bot removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Jul 17, 2024

@daxian-dbw daxian-dbw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the Invoke-ResetMethod -OutFile -Passthru needs to be updated accordingly to have the similar behavior, doesn't it?

string outFilePath = WebResponseHelper.GetOutFilePath(response, _qualifiedOutFile);

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Jul 18, 2024
@iSazonov

Copy link
Copy Markdown
Collaborator

I guess the Invoke-ResetMethod -OutFile -Passthru needs to be updated accordingly to have the similar behavior, doesn't it?

I didn't find WebResponseObject there. It is seem used only in Invoke-WebRequest.


But I found WebResponseObject and BasicHtmlWebResponseObject in PowerShellCore_format_ps1xml.cs. I believe it would be useful to add new Outfile property in the formatting.

@daxian-dbw

daxian-dbw commented Jul 22, 2024

Copy link
Copy Markdown
Member

I guess the Invoke-ResetMethod -OutFile -Passthru needs to be updated accordingly to have the similar behavior, doesn't it?

The Invoke-RestMethod does support -OutFile and -Passthru to be specified together, so the file information should be kept in the returned object just like Invoke-WebRequest, isn't it?

@mklement0

mklement0 commented Jul 23, 2024

Copy link
Copy Markdown
Contributor

@daxian-dbw: Invoke-RestMethod -PassThru -OutFile is currently broken:

If it did / once it does work as intended, what would be passed through is data (possibly parsed into a [pscustomobject] graph / an[xml] DOM), not a WebResponseObject instance.

…Cmdlet/CoreCLR/InvokeWebRequestCommand.CoreClr.cs
@daxian-dbw

Copy link
Copy Markdown
Member

@mklement0 Thanks for pointing to that issue. I didn't know it's currently broken. I re-opened it.

@daxian-dbw daxian-dbw enabled auto-merge (squash) July 23, 2024 20:30
@daxian-dbw daxian-dbw merged commit 9995125 into PowerShell:master Jul 23, 2024
@microsoft-github-policy-service

microsoft-github-policy-service Bot commented Jul 23, 2024

Copy link
Copy Markdown
Contributor

📣 Hey @jshigetomi, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

@iSazonov iSazonov added CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log and removed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels Jul 24, 2024
@jshigetomi jshigetomi deleted the issue-21082-fix branch July 24, 2024 15:36
chrisdent-de pushed a commit to chrisdent-de/PowerShell that referenced this pull request Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invoke-WebRequest -PassThru, when combined with -OutFile, should reflect the download file path.

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.