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

Closed
urbanishimwe opened this issue Jul 28, 2020 · 7 comments
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@urbanishimwe
Copy link

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

@gopherbot remove Documentation

@cagedmantis cagedmantis added this to the Backlog milestone Jul 29, 2020
@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 29, 2020
@cagedmantis
Copy link
Contributor

/cc @bradfitz @bcmills

@bcmills
Copy link
Contributor

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?)

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 31, 2020
@urbanishimwe
Copy link
Author

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, "")
}

@gopherbot gopherbot removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Aug 2, 2020
@bradfitz
Copy link
Contributor

bradfitz commented Oct 6, 2020

I'd never heard of 505. Seems fine.

/cc @neild

@bradfitz bradfitz added NeedsFix The path to resolution is known, but the work has not been done. help wanted labels Oct 6, 2020
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 6, 2020
@urbanishimwe
Copy link
Author

I think the ": unsupported protocol version" after "400 Bad Request" shouldn't be there.
since the response has body, it could be nice to provide Content-Length header for easy parsing(?)

@gopherbot
Copy link

Change https://golang.org/cl/261977 mentions this issue: net/http: return 505 status for rejected protocol version

@golang golang locked and limited conversation to collaborators Oct 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants