From 11ac3309f7227ea2320f08e366421c15ab859760 Mon Sep 17 00:00:00 2001 From: Todd Menier Date: Sun, 9 Apr 2017 10:23:21 -0500 Subject: [PATCH] test failing due to httpbin bug, but this is a better way to test quoted charset anyway --- Test/Flurl.Test.Shared/Http/GetTests.cs | 15 ++++++++++++++- Test/Flurl.Test.Shared/Http/RealHttpTests.cs | 19 ------------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/Test/Flurl.Test.Shared/Http/GetTests.cs b/Test/Flurl.Test.Shared/Http/GetTests.cs index 718cd4d7..1ae6e6f3 100644 --- a/Test/Flurl.Test.Shared/Http/GetTests.cs +++ b/Test/Flurl.Test.Shared/Http/GetTests.cs @@ -137,7 +137,20 @@ public async Task can_get_null_json_when_timeout_and_exception_handled() { Assert.IsNull(data); } - private class TestData + // https://github.com/tmenier/Flurl/pull/76 + // quotes around charset value is technically legal but there's a bug in .NET we want to avoid: https://github.com/dotnet/corefx/issues/5014 + [Test] + public async Task can_get_string_with_quoted_charset_header() { + var content = new StringContent("foo"); + content.Headers.Clear(); + content.Headers.Add("Content-Type", "text/javascript; charset=\"UTF-8\""); + HttpTest.RespondWith(content); + + var resp = await "http://api.com".GetStringAsync(); // without StripCharsetQuotes, this fails + Assert.AreEqual("foo", resp); + } + + private class TestData { public int id { get; set; } public string name { get; set; } diff --git a/Test/Flurl.Test.Shared/Http/RealHttpTests.cs b/Test/Flurl.Test.Shared/Http/RealHttpTests.cs index 62bf4095..a7145f09 100644 --- a/Test/Flurl.Test.Shared/Http/RealHttpTests.cs +++ b/Test/Flurl.Test.Shared/Http/RealHttpTests.cs @@ -168,25 +168,6 @@ public async Task can_post_multipart() { } } - // https://github.com/tmenier/Flurl/pull/76 - // quotes around charset value is technically legal but there's a bug in .NET we want to avoid: https://github.com/dotnet/corefx/issues/5014 - [Test] - public async Task supports_quoted_charset() { - // Respond with header Content-Type: text/javascript; charset="UTF-8" - var url = "https://httpbin.org/response-headers?Content-Type=text/javascript;%20charset=%22UTF-8%22"; - - // confirm thart repsonse has quoted charset value - var resp = await url.GetAsync(); - Assert.AreEqual("\"UTF-8\"", resp.Content.Headers.ContentType.CharSet); - - // GetStringAsync is where we need to work around the .NET bug - var s = await url.GetStringAsync(); - // not throwing should be enough, but do a little more for good measure.. - s = s.Trim(); - StringAssert.StartsWith("{", s); - StringAssert.EndsWith("}", s); - } - [Test] public async Task can_handle_error() { var handlerCalled = false;