minmod + rename statusCode.'Explicit()' to 'Message()'
This commit is contained in:
parent
c4863e396b
commit
5f88fede99
|
@ -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)
|
||||
|
|
|
@ -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 := ""
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue