-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
by consalus:
What steps will reproduce the problem? 1. Start a minimal webserver, such as this: package main import "http" func main() { http.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { rw.Write([]byte("RawURL: " + req.RawURL)) }) http.ListenAndServe(":8080", nil) } 2. Visit it with a bad URL, for example "http://localhost:8080/%q";. What is the expected output? It should serve a 400, or maybe log an error. What do you see instead? The browser gets a zero-byte response. Server gives no indication of what happened. Which compiler are you using (5g, 6g, 8g, gccgo)? 6g Which operating system are you using? OS X 10.5.8 Which revision are you using? (hg identify) d5785050f61d (release-branch.r59) release/release.r59 Please provide any additional information below. conn.serve checks for an error from conn.readRequest, but discards it after checking for nil. We don't have a Request (or a response) if URL parsing fails, so writing back an error isn't entirely trivial. I hacked together a local fix that works in all cases I've tested, but it is a bit inelegant and likely incomplete. Also, I'm not an expert on the http package (or http, for that matter). Still, I've attached the diff, in the off chance that it might be a useful starting point. I think the real fix will probably include a modification to the public interface, either a new error type or an additional output parameter to ReadRequest.
Attachments:
- naivefix.diff (2739 bytes)