Skip to content
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.
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 @@ -1616,7 +1616,8 @@ internal void ParseLinkHeader(HttpResponseMessage response, System.Uri requestUr
{
if (_relationLink == null)
{
_relationLink = new Dictionary<string, string>();
// Must ignore the case of relation links. See RFC 8288 (https://tools.ietf.org/html/rfc8288)
_relationLink = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,28 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
$result.Output.RelationLink["self"] | Should -BeExactly "${baseUri}?maxlinks=5&linknumber=2&type=multiple"
}


It "Validate Invoke-WebRequest RelationLink keys are treated case-insensitively" {
$uri = Get-WebListenerUrl -Test 'Link' -Query @{maxlinks = 5; linknumber = 2; type = 'multiple'}
$command = "Invoke-WebRequest -Uri '$uri'"
$result = ExecuteWebCommand -command $command

$result.Output.RelationLink["next"] | Should -Not -BeNullOrEmpty
$result.Output.RelationLink["next"] | Should -BeExactly $result.Output.RelationLink["Next"]

$result.Output.RelationLink["last"] | Should -Not -BeNullOrEmpty
$result.Output.RelationLink["last"] | Should -BeExactly $result.Output.RelationLink["LAST"]

$result.Output.RelationLink["prev"] | Should -Not -BeNullOrEmpty
$result.Output.RelationLink["prev"] | Should -BeExactly $result.Output.RelationLink["preV"]

$result.Output.RelationLink["first"] | Should -Not -BeNullOrEmpty
$result.Output.RelationLink["first"] | Should -BeExactly $result.Output.RelationLink["FiRsT"]

$result.Output.RelationLink["self"] | Should -Not -BeNullOrEmpty
$result.Output.RelationLink["self"] | Should -BeExactly $result.Output.RelationLink["self"]
}

It "Validate Invoke-WebRequest quietly ignores invalid Link Headers in RelationLink property: <type>" -TestCases @(
@{ type = "noUrl" }
@{ type = "malformed" }
Expand Down