net/http/httptest: document ResponseRecorder.Header method as an internal implementation detail, point to Result method #32136
Labels
Documentation
Issues describing a change to documentation.
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
(This is a continuation of #25763 and #16717.)
The
httptest.ResponseRecorder.HeaderMap
struct field was deprecated in CL 117675, with the deprecation notice pointing users to theResponse.Header
map as returned by theResult
method. This was to resolve issue #25763 (which provides rationale for why that was done).However, there's also a
ResponseRecorder.Header
method which does little more than provide direct access to theHeaderMap
field (it also initializes the map if it'snil
):This puts users in an awkward position. If they read the deprecation notice on the
HeaderMap
field (and understand the rationale for why it was deprecated by reading through issue #25763), and also know the internal implementation details of theHeader
method, they'll know that they shouldn't be using theHeader
method either.If they don't know the internal implementation details of the
Header
method, they won't know how it differs from theResponse.Header
map as returned by theResult
method and how to decide which one to use.Users shouldn't have to read the internal implementation of methods and make these kind of deductions. If the
HeaderMap
field is deprecated, the currentHeader
method should be too:/cc @cespare @bradfitz @dominikh
The text was updated successfully, but these errors were encountered: