Merge lp:~axwalk/juju-core/lp1235102-httpstorage-head into lp:~go-bot/juju-core/trunk
Proposed by
Andrew Wilkins
Status: | Merged |
---|---|
Approved by: | Andrew Wilkins |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1950 |
Proposed branch: | lp:~axwalk/juju-core/lp1235102-httpstorage-head |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
77 lines (+19/-8) 2 files modified
environs/httpstorage/backend.go (+17/-6) environs/httpstorage/backend_test.go (+2/-2) |
To merge this branch: | bzr merge lp:~axwalk/juju-core/lp1235102-httpstorage-head |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+189225@code.launchpad.net |
Commit message
environs/
The HEAD response was returning the listening IP
address, rather than the host presented in the
original HTTP Request. This is changed to now use
the request's Host field.
Fixes #1235102
Description of the change
environs/
The HEAD response was returning the listening IP
address, rather than the host presented in the
original HTTP Request. This is changed to now use
the request's Host field.
Fixes #1235102
To post a comment you must log in.
Reviewers: mp+189225_ code.launchpad. net,
Message:
Please take a look.
Description: httpstorage: use req.Host in HEAD
environs/
The HEAD response was returning the listening IP
address, rather than the host presented in the
original HTTP Request. This is changed to now use
the request's Host field.
Fixes #1235102
https:/ /code.launchpad .net/~axwalk/ juju-core/ lp1235102- httpstorage- head/+merge/ 189225
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/14388043/
Affected files (+19, -6 lines): httpstorage/ backend. go
A [revision details]
M environs/
Index: [revision details] 20131003170932- 4tkr0tu40wb0nfg l
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: environs/ httpstorage/ backend. go httpstorage/ backend. go' httpstorage/ backend. go 2013-10-02 05:48:00 +0000 httpstorage/ backend. go 2013-10-04 07:38:49 +0000
=== modified file 'environs/
--- environs/
+++ environs/
@@ -22,9 +22,9 @@
type storageBackend struct {
backend storage.Storage
- // httpsBaseURL is the base URL to send to clients
+ // httpsPort is the port to send to clients
// if they perform a HEAD request.
- httpsBaseURL string
+ httpsPort int
// authkey is non-empty if modifying requests authenticated. thorized) iter, req ).Set(" Location" , s.httpsBaseURL+ req.URL. Path) LastIndex( hostonly, "]"); i != -1 { LastIndex( hostonly, ":"); i != -1 { /%s:%d%s", hostonly, s.httpsPort, ).Set(" Location" , url) odNotAllowed) Close() httpsBaseURL = fmt.Sprintf("https:/ /%s", tlsListener.Addr()) Addr(). (*net.TCPAddr) .Port tlsListener, tlsBackend) listener, backend)
// require an auth key.
@@ -37,7 +37,7 @@
case "PUT", "DELETE":
// Don't allow modifying operations if there's an HTTPS backend
// to handle that, and ensure the user is authorised/
- if s.httpsBaseURL != "" || !s.authorised(req) {
+ if s.httpsPort != 0 || !s.authorised(req) {
http.Error(w, "unauthorised access", http.StatusUnau
return
}
@@ -72,8 +72,19 @@
// handleHead returns the HTTPS URL for the specified
// path in the Location header.
func (s *storageBackend) handleHead(w http.ResponseWr
*http.Request) {
- if s.httpsBaseURL != "" {
- w.Header(
+ if s.httpsPort != 0 {
+ hostonly := req.Host
+ if i := strings.
+ // [ipv6]:port
+ hostonly = hostonly[:i+1]
+ } else {
+ // host:port
+ if i := strings.
+ hostonly = hostonly[:i]
+ }
+ }
+ url := fmt.Sprintf("https:/
req.URL.Path)
+ w.Header(
} else {
http.Error(w, "method HEAD is not supported",
http.StatusMeth
return
@@ -192,7 +203,7 @@
listener.
return nil, fmt.Errorf("cannot start TLS listener: %v", err)
}
- backend.
+ backend.httpsPort = tlsListener.
goServe(
}
goServe(