Skip to content

net/http: Response.Write should write Content-Length: 0 header if present and not chunked #6762

@gopherbot

Description

@gopherbot

by islandberry23:

I am filing this issue as requested at
https://groups.google.com/forum/#!topic/golang-nuts/8D_tno7WxaY

The transferWriter decides if it should write the content-length header at:
https://code.google.com/p/go/source/browse/src/pkg/net/http/transfer.go?name=release&;r=63dcf9ca33a74dec605f6156393d719150ad6e2e#116

This function returns false for a Content-Length: 0 response unless the transfer
encoding is explicitly set to identity.  

If a response has a content length header and the transfer encoding is not explicitly
set to chunked, then the content length header should be written to the output. This is
true even of the content length is zero. Zero is a valid response body size.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions