Visitar URL original
Preserve decoded text in web response previews by huong8373tt-beep · Pull Request #28167 · PowerShell/PowerShell · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public BasicHtmlWebResponseObject(HttpResponseMessage response, Stream? contentS
/// </value>
public Encoding? Encoding { get; private set; }

/// <summary>
/// Returns the decoded text response content.
/// </summary>
/// <returns>The decoded text response content.</returns>
public override string ToString() => Content;

private WebCmdletElementCollection? _inputFields;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private void SetResponse(HttpResponseMessage response, Stream? contentStream, Ca
/// Returns the string representation of this web response.
/// </summary>
/// <returns>The string representation of this web response.</returns>
public sealed override string ToString()
public override string ToString()
{
if (Content is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {

$Result.Output.Encoding.BodyName | Should -Be 'utf-8'
$Result.Output.Content | Should -Match '⡌⠁⠧⠑ ⠼⠁⠒ ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌'
$Result.Output.ToString() | Should -Match '⡌⠁⠧⠑ ⠼⠁⠒ ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌'
}

It "Invoke-WebRequest -ContentType overwrites Content-Type from -Headers." {
Expand Down