allow empty headers on DataFromReader (#2121)
This commit is contained in:
committed by
thinkerou
parent
2ee0e96394
commit
b52a1a1588
@ -1799,6 +1799,23 @@ func TestContextRenderDataFromReader(t *testing.T) {
|
||||
assert.Equal(t, extraHeaders["Content-Disposition"], w.Header().Get("Content-Disposition"))
|
||||
}
|
||||
|
||||
func TestContextRenderDataFromReaderNoHeaders(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
c, _ := CreateTestContext(w)
|
||||
|
||||
body := "#!PNG some raw data"
|
||||
reader := strings.NewReader(body)
|
||||
contentLength := int64(len(body))
|
||||
contentType := "image/png"
|
||||
|
||||
c.DataFromReader(http.StatusOK, contentLength, contentType, reader, nil)
|
||||
|
||||
assert.Equal(t, http.StatusOK, w.Code)
|
||||
assert.Equal(t, body, w.Body.String())
|
||||
assert.Equal(t, contentType, w.Header().Get("Content-Type"))
|
||||
assert.Equal(t, fmt.Sprintf("%d", contentLength), w.Header().Get("Content-Length"))
|
||||
}
|
||||
|
||||
type TestResponseRecorder struct {
|
||||
*httptest.ResponseRecorder
|
||||
closeChannel chan bool
|
||||
|
Reference in New Issue
Block a user