Code review updates.
diff --git a/util/util.go b/util/util.go index 263b317..4178030 100644 --- a/util/util.go +++ b/util/util.go
@@ -32,7 +32,7 @@ return uuid.New().String() } - +// Helper method that initializes the roundtripper based on the configuration parameters. func Transport(pURL string) *http.Transport { var tr http.Transport if pURL != "" { @@ -43,9 +43,6 @@ tr = http.Transport{ Proxy: http.ProxyURL(paURL), } - } else { - tr = http.Transport{ - } } return &tr }
diff --git a/util/util_test.go b/util/util_test.go index 8ca741b..b6c1093 100644 --- a/util/util_test.go +++ b/util/util_test.go
@@ -72,6 +72,7 @@ })) fwdPrxyServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { Expect(r.Header.Get("foo")).Should(Equal("bar")) + w.Header().Set("bar", "foo") })) tr = util.Transport(fwdPrxyServer.URL) tr.MaxIdleConnsPerHost = maxIdleConnsPerHost @@ -82,26 +83,22 @@ go func(client *http.Client) { defer GinkgoRecover() req, err := http.NewRequest("GET", server.URL, nil) + Expect(err).Should(Succeed()) req.Header.Set("foo", "bar") resp, err := client.Do(req) - if err != nil { - Fail("Unable to process Client request") - } - ch <- resp + Expect(err).Should(Succeed()) + Expect(resp.Header.Get("bar")).Should(Equal("foo")) resp.Body.Close() - + ch <- resp }(client) } for { - select { - case resp := <-ch: - Expect(resp.StatusCode).To(Equal(http.StatusOK)) - if rspcnt >= 2*maxIdleConnsPerHost-1 { - return - } - rspcnt++ - default: + resp := <-ch + Expect(resp.StatusCode).To(Equal(http.StatusOK)) + if rspcnt >= 2*maxIdleConnsPerHost-1 { + return } + rspcnt++ } }, 3)