Created
October 21, 2014 16:10
-
-
Save darrelmiller/0a267ff98aa911aa7c6b to your computer and use it in GitHub Desktop.
HttpHeaders don't always preserve order
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void DoesNotPreserveHttpHeaderValueOrderOrCase() | |
{ | |
var response = new HttpResponseMessage(); | |
string input = "Private, max-age=60, s-maxage=60"; | |
response.Headers.TryAddWithoutValidation("Cache-Control", input); | |
var header = response.Headers.First(); | |
var output = string.Join(",", header.Value); | |
Assert.NotEqual(input,output); | |
} | |
[Fact] | |
public void PreserveHttpHeaderValueOrderInAcceptLang() | |
{ | |
var response = new HttpResponseMessage(); | |
string input = "fr-ca, en, fr, en-ca"; | |
response.Headers.TryAddWithoutValidation("Accept-Language", input); | |
var header = response.Headers.First(); | |
var output = string.Join(",", header.Value); | |
Assert.Equal(input, output); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment