From 0eed47a8f8c2575a34a067585dc0853d91943ac4 Mon Sep 17 00:00:00 2001 From: Jeevanandam M Date: Fri, 8 Jul 2016 09:00:13 -0700 Subject: [PATCH] code improvement at middleware#createHTTPRequest --- middleware.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/middleware.go b/middleware.go index 83d1435d..7fc0fc41 100644 --- a/middleware.go +++ b/middleware.go @@ -139,10 +139,13 @@ func createHTTPRequest(c *Client, r *Request) (err error) { r.RawRequest, err = http.NewRequest(r.Method, r.URL, r.bodyBuf) } - if err == nil { - r.RawRequest.Close = c.closeConnection + if err != nil { + return } + // Assign close connection option + r.RawRequest.Close = c.closeConnection + // Add headers into http request r.RawRequest.Header = r.Header @@ -151,6 +154,7 @@ func createHTTPRequest(c *Client, r *Request) (err error) { r.RawRequest.AddCookie(cookie) } + // it's for non-http scheme option if r.RawRequest.URL != nil && r.RawRequest.URL.Scheme == "" { r.RawRequest.URL.Scheme = c.scheme r.RawRequest.URL.Host = r.URL