-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BackingImage does not download URL correctly in some situation
Remove the `Referer` header that is automatically added by the http client. Without this header it is possible to download files that are redirected several times. This mimics the behaviour of `curl` and `wget` which do not submit the `referer` header by default. Signed-off-by: Volker Theile <vtheile@suse.com>
- Loading branch information
Showing
2 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package sync | ||
|
||
import ( | ||
. "gopkg.in/check.v1" | ||
"net/http" | ||
) | ||
|
||
type TestSuite struct{} | ||
|
||
var _ = Suite(&TestSuite{}) | ||
|
||
func (s *TestSuite) TestRemoveReferer(c *C) { | ||
req, err := http.NewRequest("HEAD", "https://foo.bar", nil) | ||
c.Assert(err, IsNil) | ||
req.Header.Set("Referer", "https://foo.bar") | ||
req.Header.Set("Foo", "foo") | ||
removeReferer(req) | ||
c.Assert(req.Referer(), Equals, "") | ||
c.Assert(req.Header, HasLen, 1) | ||
} |