Skip to content

Commit

Permalink
gofix for release r59
Browse files Browse the repository at this point in the history
  • Loading branch information
justinfx committed Aug 4, 2011
1 parent 5e3aa66 commit 63b6803
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions connection.go
Expand Up @@ -242,9 +242,9 @@ func (c *Conn) receive(data []byte) {
c.sio.Log("sio/conn: receive/decode:", err, c)
return
}

c.ticker.Reset(c.sio.config.HeartbeatInterval)

for _, m := range msgs {
if hb, ok := m.heartbeat(); ok {
c.lastHeartbeat = hb
Expand Down
22 changes: 11 additions & 11 deletions socketio.go
Expand Up @@ -22,10 +22,10 @@ type SocketIO struct {

// The callbacks set by the user
callbacks struct {
onConnect func(*Conn) // Invoked on new connection.
onDisconnect func(*Conn) // Invoked on a lost connection.
onMessage func(*Conn, Message) // Invoked on a message.
isAuthorized func(*http.Request) bool // Auth test during new http request
onConnect func(*Conn) // Invoked on new connection.
onDisconnect func(*Conn) // Invoked on a lost connection.
onMessage func(*Conn, Message) // Invoked on a message.
isAuthorized func(*http.Request) bool // Auth test during new http request
}
}

Expand Down Expand Up @@ -146,13 +146,13 @@ func (sio *SocketIO) handle(t Transport, w http.ResponseWriter, req *http.Reques
var parts []string
var c *Conn
var err os.Error

if allowed := sio.isAuthorized(req); !allowed {
sio.Log("sio/handle: unauthorized request:", req)
w.WriteHeader(http.StatusUnauthorized)
return
return
}

if origin := req.Header.Get("Origin"); origin != "" {
if _, ok := sio.verifyOrigin(origin); !ok {
sio.Log("sio/handle: unauthorized origin:", origin)
Expand Down Expand Up @@ -185,7 +185,7 @@ func (sio *SocketIO) handle(t Transport, w http.ResponseWriter, req *http.Reques
pathLen--
}

parts = strings.Split(req.URL.Path[i:pathLen], "/", -1)
parts = strings.Split(req.URL.Path[i:pathLen], "/")
}

if len(parts) < 2 || parts[1] == "" {
Expand Down Expand Up @@ -267,10 +267,10 @@ func (sio *SocketIO) verifyOrigin(reqOrigin string) (string, bool) {
return "", false
}

host := strings.Split(url.Host, ":", 2)
host := strings.SplitN(url.Host, ":", 2)

for _, o := range sio.config.Origins {
origin := strings.Split(o, ":", 2)
origin := strings.SplitN(o, ":", 2)
if origin[0] == "*" || origin[0] == host[0] {
if len(origin) < 2 || origin[1] == "*" {
return o, true
Expand Down Expand Up @@ -306,7 +306,7 @@ func (sio *SocketIO) generatePolicyFile() []byte {

if sio.config.Origins != nil {
for _, origin := range sio.config.Origins {
parts := strings.Split(origin, ":", 2)
parts := strings.SplitN(origin, ":", 2)
if len(parts) < 1 {
continue
}
Expand Down

0 comments on commit 63b6803

Please sign in to comment.