return StatusOK from an empty ResponseHeader.StatusCode()

This commit is contained in:
Aliaksandr Valialkin
2016-06-06 14:08:53 +03:00
parent 90baa054bc
commit 661978870b
2 changed files with 11 additions and 3 deletions
+3 -3
View File
@@ -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()
+8
View File
@@ -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"