mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-16 16:17:38 +03:00
Empty request method is equivalent to GET
This commit is contained in:
@@ -69,7 +69,7 @@ type RequestHeader struct {
|
||||
|
||||
// IsMethodGet returns true if request method is GET.
|
||||
func (h *RequestHeader) IsMethodGet() bool {
|
||||
return bytes.Equal(h.Method, strGet)
|
||||
return bytes.Equal(h.Method, strGet) || len(h.Method) == 0
|
||||
}
|
||||
|
||||
// IsMethodPost returns true if request methos is POST.
|
||||
|
||||
@@ -10,6 +10,20 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRequestHeaderEmptyMethod(t *testing.T) {
|
||||
var h RequestHeader
|
||||
|
||||
if !h.IsMethodGet() {
|
||||
t.Fatalf("empty method must be equivalent to GET")
|
||||
}
|
||||
if h.IsMethodPost() {
|
||||
t.Fatalf("empty method cannot be POST")
|
||||
}
|
||||
if h.IsMethodHead() {
|
||||
t.Fatalf("empty method cannot be HEAD")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResponseHeaderHTTPVer(t *testing.T) {
|
||||
// non-http/1.1
|
||||
testResponseHeaderHTTPVer(t, "HTTP/1.0 200 OK\r\nContent-Type: aaa\r\nContent-Length: 123\r\n\r\n", true)
|
||||
|
||||
Reference in New Issue
Block a user