Skip to content

net/http/httptest: ResponseRecorder doesn't match reality #15560

@niemeyer

Description

@niemeyer

In an attempt to fix the behavior of httptest.ResponseRecorder to mimic reality more closely (issues #8857 and #14914), commit c69e686 broke reality in the opposite end: now the recorder will not display headers unless one of Write, WriteHeader, or Flush, is called explicitly, which is not what happens on an actual handler.

This broke actual tests we had in 1.6 after running with the httptest package from tip.

As a suggested fix for both cases, the recorded headers should be frozen when Write or WriteHeader is observed, rather than completely hidden from tests until then.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions