diff options
author | tyltr <tylitianrui@126.com> | 2021-09-06 18:06:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-06 12:06:21 +0200 |
commit | f0a21893b9800871d38181863b03692cb58678d9 (patch) | |
tree | e717b35338c620036bcc50e26ae2b0418d83fdb6 /header.go | |
parent | Update status.go (#1093) (diff) | |
download | fasthttp-f0a21893b9800871d38181863b03692cb58678d9.tar.gz fasthttp-f0a21893b9800871d38181863b03692cb58678d9.tar.bz2 fasthttp-f0a21893b9800871d38181863b03692cb58678d9.zip |
feat: improve IsMethod (#1088)
* feat: improve bytesEqual
* benchmark
* nolint:unused
* remove unused code
* Update client.go
Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
Diffstat (limited to 'header.go')
-rw-r--r-- | header.go | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -443,7 +443,7 @@ func (h *RequestHeader) SetRefererBytes(referer []byte) { // Method returns HTTP request method. func (h *RequestHeader) Method() []byte { if len(h.method) == 0 { - return strGet + return []byte(MethodGet) } return h.method } @@ -503,47 +503,47 @@ func (h *RequestHeader) SetRequestURIBytes(requestURI []byte) { // IsGet returns true if request method is GET. func (h *RequestHeader) IsGet() bool { - return bytes.Equal(h.Method(), strGet) + return string(h.Method()) == MethodGet } // IsPost returns true if request method is POST. func (h *RequestHeader) IsPost() bool { - return bytes.Equal(h.Method(), strPost) + return string(h.Method()) == MethodPost } // IsPut returns true if request method is PUT. func (h *RequestHeader) IsPut() bool { - return bytes.Equal(h.Method(), strPut) + return string(h.Method()) == MethodPut } // IsHead returns true if request method is HEAD. func (h *RequestHeader) IsHead() bool { - return bytes.Equal(h.Method(), strHead) + return string(h.Method()) == MethodHead } // IsDelete returns true if request method is DELETE. func (h *RequestHeader) IsDelete() bool { - return bytes.Equal(h.Method(), strDelete) + return string(h.Method()) == MethodDelete } // IsConnect returns true if request method is CONNECT. func (h *RequestHeader) IsConnect() bool { - return bytes.Equal(h.Method(), strConnect) + return string(h.Method()) == MethodConnect } // IsOptions returns true if request method is OPTIONS. func (h *RequestHeader) IsOptions() bool { - return bytes.Equal(h.Method(), strOptions) + return string(h.Method()) == MethodOptions } // IsTrace returns true if request method is TRACE. func (h *RequestHeader) IsTrace() bool { - return bytes.Equal(h.Method(), strTrace) + return string(h.Method()) == MethodTrace } // IsPatch returns true if request method is PATCH. func (h *RequestHeader) IsPatch() bool { - return bytes.Equal(h.Method(), strPatch) + return string(h.Method()) == MethodPatch } // IsHTTP11 returns true if the request is HTTP/1.1. |