Commit 04466216 authored by Hooman's avatar Hooman
Browse files

Added support for passing URLs

parent 6dc990ad
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -43,6 +43,7 @@ import (
	"net"
	"net"
	"net/http"
	"net/http"
	"strings"
	"strings"
	"net/url"
)
)


// Settings for potential WebSocket connections. Subprotocols is a list of
// Settings for potential WebSocket connections. Subprotocols is a list of
@@ -87,6 +88,9 @@ type WebSocket struct {
	// Buffer for message payloads, which may be interrupted by control
	// Buffer for message payloads, which may be interrupted by control
	// messages.
	// messages.
	messageBuf bytes.Buffer
	messageBuf bytes.Buffer
	// Request URL
	ReqURL url.URL

}
}


func applyMask(payload []byte, maskKey [4]byte) {
func applyMask(payload []byte, maskKey [4]byte) {
@@ -333,10 +337,14 @@ func (handler *HTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
		httpError(w, bufrw, http.StatusMethodNotAllowed)
		httpError(w, bufrw, http.StatusMethodNotAllowed)
		return
		return
	}
	}

	/* URLs are accepted
	if req.URL.Path != "/" {
	if req.URL.Path != "/" {
		httpError(w, bufrw, http.StatusNotFound)
		httpError(w, bufrw, http.StatusNotFound)
		return
		return
	}
	}
	*/

	// 2. A |Host| header field containing the server's authority.
	// 2. A |Host| header field containing the server's authority.
	// We deliberately skip this test.
	// We deliberately skip this test.
	// 3. An |Upgrade| header field containing the value "websocket",
	// 3. An |Upgrade| header field containing the value "websocket",
@@ -387,6 +395,7 @@ func (handler *HTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
	ws.Bufrw = bufrw
	ws.Bufrw = bufrw
	ws.IsClient = false
	ws.IsClient = false
	ws.MaxMessageSize = handler.Config.MaxMessageSize
	ws.MaxMessageSize = handler.Config.MaxMessageSize
	ws.ReqURL =  *req.URL


	// See RFC 6455 section 4.2.2, item 5 for these steps.
	// See RFC 6455 section 4.2.2, item 5 for these steps.