diff --git a/http/upgrade/request/private.go b/http/upgrade/request/private.go index b4d5a1d..01287a3 100644 --- a/http/upgrade/request/private.go +++ b/http/upgrade/request/private.go @@ -57,6 +57,8 @@ func (r *T) parseHeader(b []byte) error { err = r.extractKey(head.Values) case header.WSPROTOCOL: fmt.Printf("[sec-websocket-protocol] ") + err = r.extractProtocols(head.Values) + default: return nil } diff --git a/http/upgrade/request/public.go b/http/upgrade/request/public.go index a6f687e..005a3a0 100644 --- a/http/upgrade/request/public.go +++ b/http/upgrade/request/public.go @@ -42,6 +42,13 @@ func Build(r io.Reader) (request *T, err error) { } + /* (4) Check completion */ + err = req.isComplete() + if err != nil { + return nil, err + } + + return req, nil } @@ -51,6 +58,10 @@ func Build(r io.Reader) (request *T, err error) { // String returns a textual representation of the upgrade request func (r T) String() string{ - return fmt.Sprintf("Upgrade Request\n - host: %s\n - port: %d\n", r.host, r.port) + l1 := fmt.Sprintf("Upgrade Request\n - host: %s\n - port: %d\n - origin: %s\n", r.host, r.port, r.origin) + l2 := fmt.Sprintf(" - origin policy: %t\n - connection header: %t\n - upgrade header: %t\n - valid ws version: %t\n", r.validPolicy, r.hasConnection, r.hasUpgrade, r.hasVersion) + l3 := fmt.Sprintf(" - key: %s\n - protocols: %s\n", r.key, r.protocols) + + return fmt.Sprintf("%s%s%s", l1, l2, l3) } \ No newline at end of file