Skip to content

net/http: 400 Bad Request not logged #12745

Closed
@kennygrant

Description

@kennygrant

Currently at net/http/server.go:1339 c.serve() responds to a bad request (e.g. http://golang.org/%L3 ) by responding with 400 Bad request without a body. This results in a blank browser window when not behind a proxy, which is not helpful for end users, and nothing in logs to indicate the cause. Would it be possible to add a simple body to this request with something like:

io.WriteString(c.rwc, "HTTP/1.1 400 Bad Request\r\n\r\n400 Bad Request")

and/or to insert a line of logging before the response:

c.server.logf("http: 400 Bad Request: %v", err)

so that the server logs all significant errors encountered during this serve() method, as it does for TLS handshake error and panics in the handlers?

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions