add handling unexpected reequest format

This commit is contained in:
xvzc 2022-03-06 17:53:22 +09:00
parent 7563f2b895
commit 1f74c89e77

View File

@ -1,6 +1,7 @@
package packet
import (
"errors"
"strings"
)
@ -139,6 +140,10 @@ func parse(raw []byte) (string, string, string, string, string, error) {
tokens := strings.Split(firstLine, " ")
if (len(tokens) < 3) {
return "", "", "", "", "", errors.New("Unexpected request format")
}
method := tokens[0]
url := tokens[1]
version := tokens[2]