Merge lp:~rvb/gwacl/handle-307 into lp:gwacl
Proposed by
Raphaël Badin
Status: | Merged |
---|---|
Approved by: | Raphaël Badin |
Approved revision: | 149 |
Merged at revision: | 152 |
Proposed branch: | lp:~rvb/gwacl/handle-307 |
Merge into: | lp:gwacl |
Diff against target: |
121 lines (+53/-5) 2 files modified
x509dispatcher.go (+5/-0) x509dispatcher_test.go (+48/-5) |
To merge this branch: | bzr merge lp:~rvb/gwacl/handle-307 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Julian Edwards (community) | Approve | ||
Review via email: mp+172330@code.launchpad.net |
Commit message
Follow temporary redirection.
Description of the change
When polling after having created or removed an instance, I've noticed that from time to time, the polling gets interrupted because it gets a 307 response (temporary redirect) from the Azure server. This branch fixes this problem by using curl's CURLOPT_
To post a comment you must log in.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
review: approve
Thanks for this, nice change. I must admit, I'm surprised that curl
doesn't do this by default, wget does.
Some minor points below.
On 01/07/13 23:08, Raphaël Badin wrote: followings allowed. +var
> === modified file 'x509dispatcher.go' --- x509dispatcher.go
> 2013-06-27 10:55:35 +0000 +++ x509dispatcher.go 2013-07-01 13:05:38
> +0000 @@ -178,6 +178,9 @@ return response, nil }
>
> +// The maximum number of redirection-
> _CURL_MAX_REDIRECTS = 10
Why did you choose 10? Document that here in the comment.
> + // makeCurlRequest produces a curl.CURL representing the curl.OPT_ KEYPASSWD, "") ch.Setopt( curl.OPT_ URL, curl.OPT_ VERBOSE, true) + curl.OPT_ FOLLOWLOCATION, true) + curl.OPT_ MAXREDIRS, _CURL_MAX_ REDIRECTS) curl.OPT_ SSLVERSION, 3) versionHeader := "x-ms-version: " versionHeader} _test.go' --- test.go 2013-03-26 10:23:51 +0000 +++ test.go 2013-07-01 13:05:38 +0000 @@ -14,9 +14,12 TPServer( requests chan *http.Request, TPServer( requests chan *http.Request, status int,
> request. // Clean up the request by calling its Cleanup() method
> after you're done // with it. @@ -188,6 +191,8 @@
> ch.Setopt(
> request.URL) //ch.Setopt(
> ch.Setopt(
> ch.Setopt(
> ch.Setopt(
> + request.APIVersion headers := []string{
>
> === modified file 'x509dispatcher
> x509dispatcher_
> x509dispatcher_
> @@ // that serves at the given base URL, copies incoming requests
> into the given // channel, and finally returns the given status
> code. If body is not nil, it // will be returned as the request
> body. -func makeRecordingHT
> status int, body []byte) *httptest.Server { +func
> makeRecordingHT
> body []byte, headers map[string]string
Consider using http.Header instead of map[string]string here (like
performRequest() in storage_base.go does), it is the same thing
underneath but conveys intent better.
) *httptest.Server { iter, r *http.Request) { status) if body rSuite) TestGetRequestD oesHTTPGET( c *C) { TPServer( httpRequests, http.StatusOK, nil) + TPServer( httpRequests, http.StatusOK, nil, "subscriptionid ", "cert.pem") @@ -72,12 +75,49 @@ httpRequest. URL.String( ), Equals, path) } rSuite) TestGetFollowsR edirects( c *C) { + REDIRECTS+ 1) + locationHeaders := string{ "Location" : redirectPath} + server := TPServer( httpRequests, http.StatusTemp oraryRedirect, "subscriptionid ", "cert.pem") +
> returnRequest := func(w http.ResponseWr
> requests <- r + for key, value := range headers { +
> w.Header().Set(key, value) + } w.WriteHeader(
> != nil { w.Write(body) @@ -55,7 +58,7 @@
>
> func (*x509Dispatche
> httpRequests := make(chan *http.Request, 1) - server :=
> makeRecordingHT
> server := makeRecordingHT
> nil) defer server.Close() // No real certificate needed since we're
> testing on http, not https. session, err :=
> newX509Session(
> c.Check(
>
> +func (*x509Dispatche
> redirectPath := "/redirect/path" + httpRequests := make(chan
> *http.Request, _CURL_MAX_
> map[string]
> makeRecordingHT
> nil, locationHeaders) + defer server.Close() + // No real
> certificate needed since we're testing on http, not https. +
> session, err := newX509Session(
> c.Assert(err, IsNil) + path := "/foo/bar...