Skip to content

Commit

Permalink
code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevatkm committed Jun 3, 2016
1 parent 061792d commit 39c3db9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,6 @@ func (c *Client) execute(req *Request) (*Response, error) {
}
}

// Do improvement here
c.mutex.Lock()

if req.proxyURL != nil {
Expand All @@ -609,6 +608,8 @@ func (c *Client) execute(req *Request) (*Response, error) {
c.httpClient.Transport = c.transport
resp, err := c.httpClient.Do(req.RawRequest)

c.mutex.Unlock()

response := &Response{
Request: req,
RawResponse: resp,
Expand All @@ -629,8 +630,6 @@ func (c *Client) execute(req *Request) (*Response, error) {
response.size = int64(len(response.body))
}

c.mutex.Unlock()

// Apply Response middleware
for _, f := range c.afterResponse {
err = f(c, response)
Expand Down
12 changes: 6 additions & 6 deletions resty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1033,9 +1033,9 @@ func TestDetectContentTypeForPointerWithSlice(t *testing.T) {
defer ts.Close()

users := &[]ExampleUser{
ExampleUser{FirstName: "firstname1", LastName: "lastname1", ZipCode: "10001"},
ExampleUser{FirstName: "firstname2", LastName: "lastname3", ZipCode: "10002"},
ExampleUser{FirstName: "firstname3", LastName: "lastname3", ZipCode: "10003"},
{FirstName: "firstname1", LastName: "lastname1", ZipCode: "10001"},
{FirstName: "firstname2", LastName: "lastname3", ZipCode: "10002"},
{FirstName: "firstname3", LastName: "lastname3", ZipCode: "10003"},
}

resp, err := dclr().
Expand Down Expand Up @@ -1080,9 +1080,9 @@ func TestDetectContentTypeForSlice(t *testing.T) {
defer ts.Close()

users := []ExampleUser{
ExampleUser{FirstName: "firstname1", LastName: "lastname1", ZipCode: "10001"},
ExampleUser{FirstName: "firstname2", LastName: "lastname3", ZipCode: "10002"},
ExampleUser{FirstName: "firstname3", LastName: "lastname3", ZipCode: "10003"},
{FirstName: "firstname1", LastName: "lastname1", ZipCode: "10001"},
{FirstName: "firstname2", LastName: "lastname3", ZipCode: "10002"},
{FirstName: "firstname3", LastName: "lastname3", ZipCode: "10003"},
}

resp, err := dclr().
Expand Down

0 comments on commit 39c3db9

Please sign in to comment.