diff options
| author | Robert Griesemer <gri@golang.org> | 2009-12-15 15:41:46 -0800 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2009-12-15 15:41:46 -0800 |
| commit | 3743fa38e180c74c51aae84eda082067e8e12523 (patch) | |
| tree | 274d1d9bf832b7834ab60c65acdf945576271d14 /src/pkg/websocket/server.go | |
| parent | 13ac778ef2f757c7cd636b4336a2bd6c8f403b43 (diff) | |
| download | golang-3743fa38e180c74c51aae84eda082067e8e12523.tar.gz | |
1) Change default gofmt default settings for
parsing and printing to new syntax.
Use -oldparser to parse the old syntax,
use -oldprinter to print the old syntax.
2) Change default gofmt formatting settings
to use tabs for indentation only and to use
spaces for alignment. This will make the code
alignment insensitive to an editor's tabwidth.
Use -spaces=false to use tabs for alignment.
3) Manually changed src/exp/parser/parser_test.go
so that it doesn't try to parse the parser's
source files using the old syntax (they have
new syntax now).
4) gofmt -w src misc test/bench
5th and last set of files.
R=rsc
CC=golang-dev
http://codereview.appspot.com/180050
Diffstat (limited to 'src/pkg/websocket/server.go')
| -rw-r--r-- | src/pkg/websocket/server.go | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/pkg/websocket/server.go b/src/pkg/websocket/server.go index e2d8cecbb..bf80f6cc0 100644 --- a/src/pkg/websocket/server.go +++ b/src/pkg/websocket/server.go @@ -5,8 +5,8 @@ package websocket import ( - "http"; - "io"; + "http" + "io" ) // Handler is a interface that use a WebSocket. @@ -39,35 +39,35 @@ func (f Handler) ServeHTTP(c *http.Conn, req *http.Request) { if req.Method != "GET" || req.Proto != "HTTP/1.1" || req.Header["Upgrade"] != "WebSocket" || req.Header["Connection"] != "Upgrade" { - c.WriteHeader(http.StatusNotFound); - io.WriteString(c, "must use websocket to connect here"); - return; + c.WriteHeader(http.StatusNotFound) + io.WriteString(c, "must use websocket to connect here") + return } - rwc, buf, err := c.Hijack(); + rwc, buf, err := c.Hijack() if err != nil { - panic("Hijack failed: ", err.String()); - return; + panic("Hijack failed: ", err.String()) + return } - defer rwc.Close(); - origin := req.Header["Origin"]; - location := "ws://" + req.Host + req.URL.Path; + defer rwc.Close() + origin := req.Header["Origin"] + location := "ws://" + req.Host + req.URL.Path // TODO(ukai): verify origin,location,protocol. - buf.WriteString("HTTP/1.1 101 Web Socket Protocol Handshake\r\n"); - buf.WriteString("Upgrade: WebSocket\r\n"); - buf.WriteString("Connection: Upgrade\r\n"); - buf.WriteString("WebSocket-Origin: " + origin + "\r\n"); - buf.WriteString("WebSocket-Location: " + location + "\r\n"); - protocol := ""; + buf.WriteString("HTTP/1.1 101 Web Socket Protocol Handshake\r\n") + buf.WriteString("Upgrade: WebSocket\r\n") + buf.WriteString("Connection: Upgrade\r\n") + buf.WriteString("WebSocket-Origin: " + origin + "\r\n") + buf.WriteString("WebSocket-Location: " + location + "\r\n") + protocol := "" // canonical header key of WebSocket-Protocol. if protocol, found := req.Header["Websocket-Protocol"]; found { buf.WriteString("WebSocket-Protocol: " + protocol + "\r\n") } - buf.WriteString("\r\n"); + buf.WriteString("\r\n") if err := buf.Flush(); err != nil { return } - ws := newConn(origin, location, protocol, buf, rwc); - f(ws); + ws := newConn(origin, location, protocol, buf, rwc) + f(ws) } |
