Skip to content

net/http/httptest: http.Response.ContentLength not set in httptest.ResponseRecorder.Result() #16952

@Thomasdezeeuw

Description

@Thomasdezeeuw

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go1.7

What operating system and processor architecture are you using (go env)?

n/a.

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

See https://play.golang.org/p/pWT6IMacni.

What did you expect to see?

Expected the Response.ContentLength to be set. Since a bytes.Buffer is used for recording the response body, the content length can be set using Buffer.Len.

What did you see instead?

As seen in https://github.com/golang/go/blob/master/src/net/http/httptest/recorder.go#L143-L188, the Response.ContentLength is never set.

I could write a patch if it would be accepted.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions