]> Cypherpunks repositories - gostls13.git/commit
net/http: support URLs without schemes in http.Redirect
authorDenys Honsiorovskyi <honsiorovskyi@gmail.com>
Wed, 2 Sep 2015 10:40:34 +0000 (13:40 +0300)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 12 Jan 2016 16:49:07 +0000 (16:49 +0000)
commiteca3618fd3977512fb9c6aded3e373b7729b952c
tree20ef25a8b840b1aa6e0be95fe745dd60be8b7132
parent27df2e3f76925701b54d9422ae5c1cac3a7d334d
net/http: support URLs without schemes in http.Redirect

Many browsers now support schemeless URLs in the Location headers
and also it is allowed in the draft HTTP/1.1 specification (see
http://stackoverflow.com/q/4831741#comment25926312_4831741), but
Go standard library lacks support for them.

This patch implements schemeless URLs support in http.Redirect().
Since url.Parse() correctly handles schemeless URLs, I've just added
an extra condition to verify URL's Host part in the absoulute/relative
check in the http.Redirect function.

Also I've moved oldpath variable initialization inside the block
of code where it is used.

Change-Id: Ib8a6347816a83e16576f00c4aa13224a89d610b5
Reviewed-on: https://go-review.googlesource.com/14172
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/net/http/serve_test.go
src/net/http/server.go