HttpStress: Add duplex operation that disposes response content (dotnet/corefx#39860)
authorEirik Tsarpalis <eirik.tsarpalis@gmail.com>
Tue, 30 Jul 2019 18:28:02 +0000 (19:28 +0100)
committerGitHub <noreply@github.com>
Tue, 30 Jul 2019 18:28:02 +0000 (19:28 +0100)
HttpStress: add duplex operation that disposes response content

Commit migrated from https://github.com/dotnet/corefx/commit/5b6a74d8455aab11f64377f3200ace1df71110ea

src/libraries/System.Net.Http/tests/StressTests/HttpStress/ClientOperations.cs

index 382e8f5..f856fc0 100644 (file)
@@ -324,6 +324,22 @@ namespace HttpStress
                         ValidateContent(content, await m.Content.ReadAsStringAsync());
                     }
                 }),
+                
+                ("POST Duplex Dispose",
+                async ctx =>
+                {
+                    // try to reproduce conditions described in https://github.com/dotnet/corefx/issues/39819
+                    string content = ctx.GetRandomString(0, ctx.MaxContentLength);
+                    Version httpVersion = ctx.GetRandomHttpVersion();
+
+                    using (var req = new HttpRequestMessage(HttpMethod.Post, "/duplex") { Version = httpVersion, Content = new StringDuplexContent(content) })
+                    using (HttpResponseMessage m = await ctx.SendAsync(req, HttpCompletionOption.ResponseHeadersRead))
+                    {
+                        ValidateHttpVersion(m, httpVersion);
+                        ValidateStatusCode(m);
+                        // Cause the response to be disposed without reading the response body, which will cause the client to cancel the request
+                    }
+                }),
 
                 ("POST ExpectContinue",
                 async ctx =>