mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
http: revised http Handler interface
R=rsc CC=golang-dev https://golang.org/cl/1993043
This commit is contained in:
parent
ffdb855be1
commit
fd9a5d22c6
11 changed files with 338 additions and 308 deletions
|
|
@ -445,16 +445,16 @@ var rpcPath string = "/_goRPC_"
|
|||
var debugPath string = "/debug/rpc"
|
||||
var connected = "200 Connected to Go RPC"
|
||||
|
||||
func serveHTTP(c *http.Conn, req *http.Request) {
|
||||
func serveHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
if req.Method != "CONNECT" {
|
||||
c.SetHeader("Content-Type", "text/plain; charset=utf-8")
|
||||
c.WriteHeader(http.StatusMethodNotAllowed)
|
||||
io.WriteString(c, "405 must CONNECT to "+rpcPath+"\n")
|
||||
w.SetHeader("Content-Type", "text/plain; charset=utf-8")
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
io.WriteString(w, "405 must CONNECT to "+rpcPath+"\n")
|
||||
return
|
||||
}
|
||||
conn, _, err := c.Hijack()
|
||||
conn, _, err := w.Hijack()
|
||||
if err != nil {
|
||||
log.Stderr("rpc hijacking ", c.RemoteAddr, ": ", err.String())
|
||||
log.Stderr("rpc hijacking ", w.RemoteAddr(), ": ", err.String())
|
||||
return
|
||||
}
|
||||
io.WriteString(conn, "HTTP/1.0 "+connected+"\n\n")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue