Added request methods
This commit is contained in:
parent
9cbbd3957a
commit
8969c32887
@ -143,7 +143,7 @@ func (s *server) handleConnection(conn net.Conn) {
|
||||
|
||||
method = message[:space]
|
||||
|
||||
if method != "GET" {
|
||||
if !isRequestMethod(method) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -1,7 +0,0 @@
|
||||
package web
|
||||
|
||||
// header is used to store HTTP headers.
|
||||
type header struct {
|
||||
Key string
|
||||
Value string
|
||||
}
|
@ -2,6 +2,22 @@ package web
|
||||
|
||||
import "strings"
|
||||
|
||||
// header is used to store HTTP headers.
|
||||
type header struct {
|
||||
Key string
|
||||
Value string
|
||||
}
|
||||
|
||||
// isRequestMethod returns true if the given string is a valid HTTP request method.
|
||||
func isRequestMethod(method string) bool {
|
||||
switch method {
|
||||
case "GET", "HEAD", "POST", "PUT", "DELETE", "CONNECT", "OPTIONS", "TRACE", "PATCH":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// parseURL parses a URL and returns the scheme, host, path and query.
|
||||
func parseURL(url string) (scheme string, host string, path string, query string) {
|
||||
schemePos := strings.Index(url, "://")
|
Loading…
Reference in New Issue
Block a user