Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Http parser does not always detect start line correctly #1580

Closed
natemcmaster opened this issue Mar 31, 2017 · 1 comment
Closed

Http parser does not always detect start line correctly #1580

natemcmaster opened this issue Mar 31, 2017 · 1 comment
Assignees

Comments

@natemcmaster
Copy link
Contributor

Multiple GET requests on the same connection can cause http request parsing errors.

Repro

using (var server = new TestServer( context =>
{
    return Task.CompletedTask;
}))
{
    using (var connection = server.CreateConnection())
    {
        for (var i = 0; i < 1000; i++)
        {
            await connection.Send("GET / HTTP/1.1",
                "Content-Length: 0",
                "Host: localhost",
                "",
                "");

            await connection.Receive($"HTTP/1.1 200 OK",
                $"Date: {server.Context.DateHeaderValue}",
                "Content-Length: 0",
                "",
                "").TimeoutAfter(TimeSpan.FromSeconds(10));
        }
    }
}

Usually within 200 requests, parsing fails with:

BadHttpRequestException: Invalid request line: ' / HTTP/1.1\x0D\x0A'

The error is not consistent. Sometimes it will be one of these:

BadHttpRequestException: Invalid request line: ' HTTP/1.1\x0D\x0A'
BadHttpRequestException: Invalid request line: '1.1\x0D\x0A'
natemcmaster pushed a commit to natemcmaster/KestrelHttpServer that referenced this issue Mar 31, 2017
@davidfowl davidfowl self-assigned this Apr 1, 2017
@davidfowl
Copy link
Member

I'll take a look at this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants