modify test to work around CL population issue
authorGeoff Kizer <geoffrek>
Mon, 19 Feb 2018 19:28:15 +0000 (11:28 -0800)
committerGeoff Kizer <geoffrek>
Mon, 19 Feb 2018 19:28:15 +0000 (11:28 -0800)
Commit migrated from https://github.com/dotnet/corefx/commit/ff5318905c9134d5fbf87b6597f72d331bc9a029

src/libraries/System.Net.Http/tests/FunctionalTests/PostScenarioTest.cs

index 5c5ee93..446fab9 100644 (file)
@@ -191,9 +191,17 @@ namespace System.Net.Http.Functional.Tests
         {
             using (HttpClient client = CreateHttpClient())
             {
-                if (!useContentLengthUpload && requestContent != null)
+                if (requestContent != null)
                 {
-                    requestContent.Headers.ContentLength = null;
+                    if (useContentLengthUpload)
+                    {
+                        // Ensure that Content-Length is populated (see issue #27245)
+                        requestContent.Headers.ContentLength = requestContent.Headers.ContentLength;
+                    }
+                    else
+                    {
+                        requestContent.Headers.ContentLength = null;
+                    }
                 }
                 
                 if (useChunkedEncodingUpload)