http_client 0.5.0-universal-java-1.7 → 0.5.1-universal-java-1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -0
- data/Gemfile.lock +12 -0
- data/LICENSE +21 -0
- data/README.md +11 -5
- data/http_client-0.5.0-universal-java-1.7.gem +0 -0
- data/http_client.gemspec +1 -1
- data/lib/http_client.rb +2 -2
- data/test/http_client_test.rb +12 -5
- metadata +4 -2
- data/http_client-0.5.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95b4ae6132833f69d4e1abc9df4a5cc203a3bbd9
|
4
|
+
data.tar.gz: ab7b401d2c75b05a6a6abf582621e41131d2f957
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c595bd6f58b7e47eb0c921327f75716df82b9574e96f0b9c82112de3158353997713f1d4060bde6eec0233b6ad3a06c28d88e831ad87c4be310feb334088e012
|
7
|
+
data.tar.gz: 504703032f7e898ed4c76e44b28fc464315a1db6cb9279bdd4b259b178fcfe209f3f2884e0a7ec3a088b218b8c1ce007684e51802585e6c711c31eed654ac430
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Lukas Rieder
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# A simple yet powerful HTTP client for JRuby
|
2
2
|
|
3
|
-
This library wraps the Apache
|
3
|
+
This library wraps the Apache HttpClient (4.3) in a simple fashion.
|
4
4
|
It currently implements all common HTTP verbs, connection pooling, retries and transparent gzip response handling. All common exceptions from Javaland are wrapped as Ruby exceptions. The library is intended to be used in a multithreaded environment.
|
5
5
|
|
6
6
|
## Examples
|
@@ -10,7 +10,7 @@ It currently implements all common HTTP verbs, connection pooling, retries and t
|
|
10
10
|
```ruby
|
11
11
|
require "http_client"
|
12
12
|
|
13
|
-
client =
|
13
|
+
client = HttpClient.new
|
14
14
|
response = client.get("http://www.google.com/robots.txt")
|
15
15
|
|
16
16
|
response.status
|
@@ -57,9 +57,9 @@ response = client.get("http://secretservice.com/users/123",
|
|
57
57
|
#### Using a connection pool
|
58
58
|
|
59
59
|
```ruby
|
60
|
-
$client =
|
60
|
+
$client = HttpClient.new(
|
61
61
|
:use_connection_pool => true,
|
62
|
-
:max_connections => 10
|
62
|
+
:max_connections => 10
|
63
63
|
)
|
64
64
|
|
65
65
|
%[www.google.de www.yahoo.com www.altavista.com].each do |host|
|
@@ -74,6 +74,12 @@ end
|
|
74
74
|
|
75
75
|
This library covers just what I need. I wanted to have a thread safe HTTP client that has a fixed connection pool with fine grained timeout configurations.
|
76
76
|
|
77
|
-
Before you start hacking away, have a look at the issues. There might be stuff that is already in the making. If so, there will be a published branch you can contribute to.
|
77
|
+
Before you start hacking away, [have a look at the issues](https://github.com/Overbryd/http_client/issues). There might be stuff that is already in the making. If so, there will be a published branch you can contribute to.
|
78
78
|
|
79
79
|
Just create a fork and send me a pull request. I would be honored to look at your input.
|
80
|
+
|
81
|
+
![Build Status](https://travis-ci.org/Overbryd/http_client.png)
|
82
|
+
|
83
|
+
## Legal
|
84
|
+
|
85
|
+
Copyright by Lukas Rieder, 2013, Licensed under the MIT License, see LICENSE
|
Binary file
|
data/http_client.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "http_client"
|
3
|
-
s.version = "0.5.
|
3
|
+
s.version = "0.5.1"
|
4
4
|
s.date = "2013-11-07"
|
5
5
|
s.summary = "HTTP client for JRuby"
|
6
6
|
s.description = "This library wraps the Apache HTTPClient (4.3) in a simple fashion. The library is intended to be used in a multithreaded environment."
|
data/lib/http_client.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require "uri"
|
4
4
|
require "java"
|
5
5
|
%w[httpcore-4.3 httpclient-4.3.1 httpmime-4.3.1 commons-logging-1.1.3].each do |jar|
|
6
|
-
|
6
|
+
require File.expand_path("../../vendor/#{jar}.jar", __FILE__)
|
7
7
|
end
|
8
8
|
|
9
9
|
class HttpClient
|
@@ -59,7 +59,7 @@ class HttpClient
|
|
59
59
|
|
60
60
|
def read_body(closeable_response)
|
61
61
|
return "" unless entity = closeable_response.entity
|
62
|
-
return "" unless entity.content_length > 0
|
62
|
+
return "" unless entity.is_chunked? || entity.content_length > 0
|
63
63
|
if content_encoding = entity.content_encoding
|
64
64
|
entity = case content_encoding.value
|
65
65
|
when "gzip", "x-gzip" then
|
data/test/http_client_test.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
require "rubygems"
|
4
|
-
|
4
|
+
require "bundler/setup"
|
5
5
|
require "minitest/pride"
|
6
6
|
require "minitest/autorun"
|
7
|
-
|
8
7
|
require "json"
|
9
|
-
|
8
|
+
|
9
|
+
require File.expand_path("../../lib/http_client", __FILE__)
|
10
|
+
|
11
|
+
def Hash(h); h; end
|
10
12
|
|
11
13
|
module Minitest
|
12
14
|
class Test
|
13
15
|
def self.test(name, &block)
|
14
|
-
define_method("test_#{name.gsub(" ", "
|
16
|
+
define_method("test_#{name.gsub(" ", "_")}", &block)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -20,7 +22,7 @@ class HttpClientTest < Minitest::Test
|
|
20
22
|
attr_reader :client
|
21
23
|
|
22
24
|
def setup
|
23
|
-
@client = HttpClient.new
|
25
|
+
@client = HttpClient.new(:socket_timeout => 5000, :connect_timeout => 5000, :max_retries => 2)
|
24
26
|
end
|
25
27
|
|
26
28
|
test "GET request with params in uri" do
|
@@ -44,6 +46,11 @@ class HttpClientTest < Minitest::Test
|
|
44
46
|
assert_nil response.json_body["headers"]["Content-Encoding"]
|
45
47
|
end
|
46
48
|
|
49
|
+
test "GET request with chunked response" do
|
50
|
+
response = client.get("http://httpbin.org/stream/10")
|
51
|
+
assert_equal 10, response.body.split("\n").size
|
52
|
+
end
|
53
|
+
|
47
54
|
test "POST request with string body" do
|
48
55
|
response = client.post("http://httpbin.org/post", :body => "foo:bar|zig:zag")
|
49
56
|
assert_equal "text/plain; charset=UTF-8", response.json_body["headers"]["Content-Type"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: universal-java-1.7
|
6
6
|
authors:
|
7
7
|
- Lukas Rieder
|
@@ -16,9 +16,11 @@ executables: []
|
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
+
- Gemfile
|
20
|
+
- Gemfile.lock
|
19
21
|
- http_client-0.5.0-universal-java-1.7.gem
|
20
|
-
- http_client-0.5.0.gem
|
21
22
|
- http_client.gemspec
|
23
|
+
- LICENSE
|
22
24
|
- README.md
|
23
25
|
- lib/http_client.rb
|
24
26
|
- test/http_client_test.rb
|
data/http_client-0.5.0.gem
DELETED
Binary file
|