mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
committed by
Aliaksandr Valialkin
parent
cefa3b1f52
commit
ae8de36df0
@@ -518,6 +518,11 @@ func (h *RequestHeader) IsHead() bool {
|
||||
return bytes.Equal(h.Method(), strHead)
|
||||
}
|
||||
|
||||
// IsDelete returns true if request method is DELETE.
|
||||
func (h *RequestHeader) IsDelete() bool {
|
||||
return bytes.Equal(h.Method(), strDelete)
|
||||
}
|
||||
|
||||
// IsHTTP11 returns true if the request is HTTP/1.1.
|
||||
func (h *RequestHeader) IsHTTP11() bool {
|
||||
return !h.noHTTP11
|
||||
|
||||
@@ -793,6 +793,9 @@ func TestRequestHeaderEmptyMethod(t *testing.T) {
|
||||
if h.IsHead() {
|
||||
t.Fatalf("empty method cannot be HEAD")
|
||||
}
|
||||
if h.IsDelete() {
|
||||
t.Fatalf("empty method cannot be DELETE")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResponseHeaderHTTPVer(t *testing.T) {
|
||||
|
||||
@@ -762,6 +762,11 @@ func (ctx *RequestCtx) IsPut() bool {
|
||||
return ctx.Request.Header.IsPut()
|
||||
}
|
||||
|
||||
// IsDelete returns true if request method is DELETE.
|
||||
func (ctx *RequestCtx) IsDelete() bool {
|
||||
return ctx.Request.Header.IsDelete()
|
||||
}
|
||||
|
||||
// Method return request method.
|
||||
//
|
||||
// Returned value is valid until returning from RequestHandler.
|
||||
|
||||
+5
-4
@@ -22,10 +22,11 @@ var (
|
||||
|
||||
strResponseContinue = []byte("HTTP/1.1 100 Continue\r\n\r\n")
|
||||
|
||||
strGet = []byte("GET")
|
||||
strHead = []byte("HEAD")
|
||||
strPost = []byte("POST")
|
||||
strPut = []byte("PUT")
|
||||
strGet = []byte("GET")
|
||||
strHead = []byte("HEAD")
|
||||
strPost = []byte("POST")
|
||||
strPut = []byte("PUT")
|
||||
strDelete = []byte("DELETE")
|
||||
|
||||
strExpect = []byte("Expect")
|
||||
strConnection = []byte("Connection")
|
||||
|
||||
Reference in New Issue
Block a user