mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-16 16:17:38 +03:00
return StatusOK from an empty ResponseHeader.StatusCode()
This commit is contained in:
@@ -116,6 +116,9 @@ func (h *RequestHeader) SetByteRange(startPos, endPos int) {
|
||||
|
||||
// StatusCode returns response status code.
|
||||
func (h *ResponseHeader) StatusCode() int {
|
||||
if h.statusCode == 0 {
|
||||
return StatusOK
|
||||
}
|
||||
return h.statusCode
|
||||
}
|
||||
|
||||
@@ -1386,9 +1389,6 @@ func (h *ResponseHeader) AppendBytes(dst []byte) []byte {
|
||||
if statusCode < 0 {
|
||||
statusCode = StatusOK
|
||||
}
|
||||
if statusCode == 0 {
|
||||
statusCode = StatusOK
|
||||
}
|
||||
dst = append(dst, statusLine(statusCode)...)
|
||||
|
||||
server := h.Server()
|
||||
|
||||
@@ -10,6 +10,14 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestResponseHeaderDefaultStatusCode(t *testing.T) {
|
||||
var h ResponseHeader
|
||||
statusCode := h.StatusCode()
|
||||
if statusCode != StatusOK {
|
||||
t.Fatalf("unexpected status code: %d. Expecting %d", statusCode, StatusOK)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResponseHeaderDelClientCookie(t *testing.T) {
|
||||
cookieName := "foobar"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user