瀏覽代碼

Modify client to work with Chrome debug server.

The Chrome debug server does not use case insensitive comparison on the
Connection header tokens as required by the HTTP RFC. Modify the client
to send "Connection: Upgrade" as expected by Chrome. Because this
matches the examples in the RFC, this change might improve
interoperability with other servers.
Gary Burd 12 年之前
父節點
當前提交
f273336ae2
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      client.go

+ 3 - 1
client.go

@@ -40,7 +40,9 @@ func NewClient(netConn net.Conn, u *url.URL, requestHeader http.Header, readBufS
 	p = append(p, u.RequestURI()...)
 	p = append(p, " HTTP/1.1\r\nHost: "...)
 	p = append(p, u.Host...)
-	p = append(p, "\r\nUpgrade: websocket\r\nConnection: upgrade\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: "...)
+	// "Upgrade" is capitalized for servers that do not use case insensitive
+	// comparisons on header tokens.
+	p = append(p, "\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: "...)
 	p = append(p, challengeKey...)
 	p = append(p, "\r\n"...)
 	for k, vs := range requestHeader {