-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Workaround http.sys bug in ResponseBodyTests for Content-Length header #64960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -212,7 +212,7 @@ public async Task ResponseBody_WriteContentLength_PassedThrough() | |
| using (Utilities.CreateHttpServer(out address, async httpContext => | ||
| { | ||
| httpContext.Features.Get<IHttpBodyControlFeature>().AllowSynchronousIO = true; | ||
| httpContext.Response.Headers["Content-lenGth"] = " 30 "; | ||
| httpContext.Response.Headers["Content-lenGth"] = "30"; | ||
|
||
| Stream stream = httpContext.Response.Body; | ||
| stream.EndWrite(stream.BeginWrite(new byte[10], 0, 10, null, null)); | ||
| stream.Write(new byte[10], 0, 10); | ||
|
|
@@ -236,7 +236,7 @@ public async Task ResponseBody_WriteContentLengthNoneWritten_Throws() | |
| string address; | ||
| using (Utilities.CreateHttpServer(out address, httpContext => | ||
| { | ||
| httpContext.Response.Headers["Content-lenGth"] = " 20 "; | ||
| httpContext.Response.Headers["Content-lenGth"] = "20"; | ||
| return Task.FromResult(0); | ||
| }, LoggerFactory)) | ||
| { | ||
|
|
@@ -250,7 +250,7 @@ public async Task ResponseBody_WriteContentLengthNotEnoughWritten_Throws() | |
| string address; | ||
| using (Utilities.CreateHttpServer(out address, httpContext => | ||
| { | ||
| httpContext.Response.Headers["Content-lenGth"] = " 20 "; | ||
| httpContext.Response.Headers["Content-lenGth"] = "20"; | ||
| return httpContext.Response.Body.WriteAsync(new byte[5], 0, 5); | ||
| }, LoggerFactory)) | ||
| { | ||
|
|
@@ -265,7 +265,7 @@ public async Task ResponseBody_WriteContentLengthTooMuchWritten_Throws() | |
| string address; | ||
| using (Utilities.CreateHttpServer(out address, async httpContext => | ||
| { | ||
| httpContext.Response.Headers["Content-lenGth"] = " 10 "; | ||
| httpContext.Response.Headers["Content-lenGth"] = "10"; | ||
| await httpContext.Response.Body.WriteAsync(new byte[5], 0, 5); | ||
| await Assert.ThrowsAsync<InvalidOperationException>(() => | ||
| httpContext.Response.Body.WriteAsync(new byte[6], 0, 6)); | ||
|
|
@@ -286,7 +286,7 @@ public async Task ResponseBody_WriteContentLengthExtraWritten_Throws() | |
| try | ||
| { | ||
| httpContext.Features.Get<IHttpBodyControlFeature>().AllowSynchronousIO = true; | ||
| httpContext.Response.Headers["Content-lenGth"] = " 10 "; | ||
| httpContext.Response.Headers["Content-lenGth"] = "10"; | ||
| httpContext.Response.Body.Write(new byte[10], 0, 10); | ||
| httpContext.Response.Body.Write(new byte[9], 0, 9); | ||
| requestThrew.SetResult(false); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description mentions a bug filed on the http.sys team and that this is a workaround, but there is no code comment, issue link, or documentation explaining what the http.sys bug is, why spaces in the Content-Length header value trigger it, or when this workaround can be removed. Consider adding a comment with a reference to the filed bug to help future maintainers understand why the spaces were removed.