diff --git a/internal/http/upgrade/request/public.go b/internal/http/upgrade/request/public.go index cd57f17..12eb5d7 100644 --- a/internal/http/upgrade/request/public.go +++ b/internal/http/upgrade/request/public.go @@ -64,7 +64,7 @@ func (r T) String() string{ 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) - l4 := fmt.Sprintf(" - current status: %d %s\n", r.code, r.code.Explicit()) + l4 := fmt.Sprintf(" - current status: %d %s\n", r.code, r.code.Message()) return fmt.Sprintf("%s%s%s%s", l1, l2, l3, l4) diff --git a/internal/http/upgrade/response/public.go b/internal/http/upgrade/response/public.go index bd46d61..e575fe8 100644 --- a/internal/http/upgrade/response/public.go +++ b/internal/http/upgrade/response/public.go @@ -40,7 +40,7 @@ func (r *T) ProcessKey(k []byte) { func (r T) Send(w io.Writer) (int, error) { /* (1) Build response line */ - responseLine := fmt.Sprintf("HTTP/%s %d %s\r\n", HttpVersion, r.code, r.code.Explicit()) + responseLine := fmt.Sprintf("HTTP/%s %d %s\r\n", HttpVersion, r.code, r.code.Message()) /* (2) Build headers */ optionalProtocol := "" diff --git a/internal/http/upgrade/response/status_code.go b/internal/http/upgrade/response/status_code.go index a033e03..56ac52f 100644 --- a/internal/http/upgrade/response/status_code.go +++ b/internal/http/upgrade/response/status_code.go @@ -10,7 +10,7 @@ var UPGRADE_REQUIRED StatusCode = 426 // invalid WS version var NOT_FOUND StatusCode = 404 // unserved or invalid URI var INTERNAL StatusCode = 500 // custom error -func (sc StatusCode) Explicit() string { +func (sc StatusCode) Message() string { switch sc { case SWITCHING_PROTOCOLS: return "Switching Protocols" diff --git a/upgrader/public.go b/upgrader/public.go index c6c978a..a606c62 100644 --- a/upgrader/public.go +++ b/upgrader/public.go @@ -18,7 +18,7 @@ func Upgrade(s net.Conn) error { /* (3) Write into socket */ _, err := res.Send(s) if err != nil { - return fmt.Errorf("Socket write: %s", err) + return fmt.Errorf("Socket write error: %s", err) } return nil