Skip to content

Commit

Permalink
code improvement at middleware#createHTTPRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevatkm committed Jul 8, 2016
1 parent 2cc8417 commit 0eed47a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 0eed47a

Please sign in to comment.