Skip to content

Commit

Permalink
Added httpclient
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Jul 27, 2015
1 parent 2974663 commit 7e53bbe
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ gem "geocoder"
gem "koala"
gem "httparty"
gem "hipchat"
gem "httpclient"
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ GEM
httparty (0.13.5)
json (~> 1.8)
multi_xml (>= 0.5.2)
httpclient (2.6.0.1)
i18n (0.7.0)
json (1.8.3)
jwt (1.5.1)
Expand Down Expand Up @@ -110,6 +111,7 @@ DEPENDENCIES
hipchat
http
httparty
httpclient
koala
minitest
mongo
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ HTTP Clients
- [open-uri](#open-uri)
- [http](#http)
- [httparty](#httparty)
- [httpclient](#httpclient)
- [rest-client](#rest-client)
- [faraday](#faraday)
- [curb](#curb)
Expand Down Expand Up @@ -212,6 +213,21 @@ Raises:
- `Net::OpenTimeout` on connect timeout
- `Net::ReadTimeout` on read timeout

### httpclient

```ruby
client = HTTPClient.new
client.connect_timeout = 1
client.receive_timeout = 1
client.send_timeout = 1
client.get(url)
```

Raises:

- `HTTPClient::ConnectTimeoutError` on connect timeout
- `HTTPClient::ReceiveTimeoutError` on read timeout

### rest-client

```ruby
Expand Down
19 changes: 19 additions & 0 deletions test/httpclient_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require_relative "test_helper"

class HttpClientTest < Minitest::Test
def test_connect
assert_timeout(HTTPClient::ConnectTimeoutError) do
client = HTTPClient.new
client.connect_timeout = 1
client.get(connect_url)
end
end

def test_read
assert_timeout(HTTPClient::ReceiveTimeoutError) do
client = HTTPClient.new
client.receive_timeout = 1
client.get(read_url)
end
end
end

0 comments on commit 7e53bbe

Please sign in to comment.