Skip to content

http.DefaultTransport mutates the http.Request #2140

@gopherbot

Description

@gopherbot

by dgrijalva@ngmoco.com:

What steps will reproduce the problem?
1. use the DefaultTransport's RoundTrip method with an http.Request that does not have
the Accept-Encoding header
2. check the Accept-Encoding header after the round trip
3.

What is the expected output?
the Accept-Encoding header should be unmodified

What do you see instead?
the Accept-Encoding header is set to "gzip"

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
mac, ubuntu

Which revision are you using?  (hg identify)
bb28251f6da4+ weekly/weekly.2011-07-29

Please provide any additional information below.

The default round tripper (cleverly) uses gzip encoding transparently when making
upstream requests for a client that doesn't support compression.  The trouble is that it
mutates the http.Request struct and doesn't put it back.  This breaks any software that
looks at the request after performing the round trip.

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