This commit is contained in:
Tracer Tong
2016-05-28 00:54:11 +09:00
committed by Aliaksandr Valialkin
parent cefa3b1f52
commit ae8de36df0
4 changed files with 18 additions and 4 deletions
+5
View File
@@ -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
+3
View File
@@ -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) {
+5
View File
@@ -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
View File
@@ -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")