Skip to content

Conversation

@jshigetomi
Copy link
Collaborator

@jshigetomi jshigetomi commented Jul 12, 2024

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
Copy link
Collaborator

@iSazonov iSazonov left a comment

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
Collaborator

@mklement0 Please review.

/// <summary>
/// Gets or sets the output file path.
/// </summary>
public string? OutFile { get; set; }
Copy link
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
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
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
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
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
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
Copy link
Member

@daxian-dbw daxian-dbw left a comment

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
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
Copy link
Member

daxian-dbw commented Jul 22, 2024

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
Copy link
Contributor

mklement0 commented Jul 23, 2024

@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
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
Copy link
Contributor

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

📣 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