Skip to content
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

net/http: wrong/undocumented response behaviors when unsupported HTTP version is used #40454

Open
urbanishimwe opened this issue Jul 28, 2020 · 4 comments
Milestone

Comments

@urbanishimwe
Copy link

@urbanishimwe urbanishimwe commented Jul 28, 2020

What version of Go are you using (go version)?

$ go version
go version go1.14.6 linux/amd64

Does this issue reproduce with the latest release?

yes

What did you do?

created a server with the most minimal configurations

package main

import (
        "fmt"
        "net/http"
)

func main() {
        if err := http.ListenAndServe(":8001", http.HandlerFunc(handler)); err != nil {
                fmt.Println(err)
        }
}

func handler(w http.ResponseWriter, r *http.Request) {
        fmt.Fprint(w, "")
}

made a TCP request

printf "GET / HTTP/2.0\r\nHOST: 127.0.0.1:80\r\n\r\n" | nc 127.0.0.1 8001

What did you expect to see?

as in https://tools.ietf.org/html/rfc7231#section-6.6.6

505 HTTP Version Not Supported\r\n...

What did you see instead?

HTTP/1.1 400 Bad Request: unsupported protocol version\r\nContent-Type: text/plain; charset=utf-8\r\nConnection: close\r\n\r\n400 Bad Request: unsupported protocol version

I think the server should also indicate the body length if there is any.

@networkimprov
Copy link

@networkimprov networkimprov commented Jul 28, 2020

@gopherbot remove Documentation

@cagedmantis cagedmantis added this to the Backlog milestone Jul 29, 2020
@cagedmantis
Copy link
Contributor

@cagedmantis cagedmantis commented Jul 29, 2020

@bcmills
Copy link
Member

@bcmills bcmills commented Jul 31, 2020

Please provide the steps to reproduce as a Go program, not (just) a Unix command-line. (How did you configure the server on the Go side?)

@urbanishimwe
Copy link
Author

@urbanishimwe urbanishimwe commented Jul 31, 2020

(How did you configure the server on the Go side?)

Basic configurations like this can reproduce the issue

package main

import (
        "fmt"
        "net/http"
)

func main() {
        if err := http.ListenAndServe(":8001", http.HandlerFunc(handler)); err != nil {
                fmt.Println(err)
        }
}

func handler(w http.ResponseWriter, r *http.Request) {
        fmt.Fprint(w, "")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.