added 'String()' to check upgrade request
This commit is contained in:
parent
4df664a138
commit
5649c49837
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
Loading…
Reference in New Issue