Closed
Description
The following program fails with the panic:
package main
import (
"bufio"
"bytes"
"net/http"
)
func main() {
data := []byte("M-SEARCH * HTTP/1.1\n\n")
r, err := http.ReadRequest(bufio.NewReader(bytes.NewReader(data)))
if err != nil {
return
}
buf := new(bytes.Buffer)
if err := r.Write(buf); err != nil {
return
}
_, err = http.ReadRequest(bufio.NewReader(buf))
if err != nil {
panic(err)
}
}
panic: parse %2A: invalid URI for request
Star is a common path for some request types. It is handled by a special path in URL.Parse, but URL.String generated %2A for it, which is an invalid path.
go version devel +a1fe3b5 Sat Jun 13 04:33:26 2015 +0000 linux/amd64