emmy-http-client 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/emmy-http-client.gemspec +1 -0
- data/example/Gemfile +3 -0
- data/example/Gemfile.lock +43 -0
- data/example/simple.rb +19 -0
- data/lib/emmy_http/client/client.rb +10 -15
- data/lib/emmy_http/client/version.rb +1 -1
- metadata +21 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0817f9c453e0652d1a0911177cca1feb40a2a9a2
|
4
|
+
data.tar.gz: f303d956e687752b0bf90649a9bdb0fe3b8f5fa1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32dc9b70af63d31f3f108520035d5c60224d8711ef8f643c7c7513fbb9796b1010e71ec2f9d2249e21c4aa603ee8c6189482f3ecf7d9e6e68e1425f5e92b9447
|
7
|
+
data.tar.gz: 7b892786b160e6907b41d92b2b7d5d320554026f7c9a762f966165aad9ef6b704f8f5418093e1cfa5c4b44bd66e9e018170aa62be61d0e3a40b87820e0d9fff2
|
data/emmy-http-client.gemspec
CHANGED
data/example/Gemfile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
emmy-http-client (0.1.9)
|
5
|
+
addressable (>= 2.3.8)
|
6
|
+
emmy-machine (~> 0.1.7)
|
7
|
+
event_object (~> 0.9.1)
|
8
|
+
fibre (~> 0.9.7)
|
9
|
+
http_parser.rb (= 0.6.0)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
specs:
|
13
|
+
addressable (2.3.8)
|
14
|
+
emmy (0.2.3)
|
15
|
+
emmy-engine (~> 0.1)
|
16
|
+
eventmachine (~> 1.0)
|
17
|
+
emmy-engine (0.2.8)
|
18
|
+
emmy-http (~> 0.2)
|
19
|
+
emmy-http-client (~> 0.1)
|
20
|
+
emmy-machine (~> 0.1)
|
21
|
+
emmy-http (0.2.8)
|
22
|
+
addressable (~> 2.3)
|
23
|
+
emmy-machine (~> 0.1)
|
24
|
+
event_object (~> 0.9)
|
25
|
+
fibre (~> 0.9)
|
26
|
+
model_pack (~> 0.9)
|
27
|
+
util_pack (~> 0.1)
|
28
|
+
emmy-machine (0.1.12)
|
29
|
+
fibre (~> 0.9.9)
|
30
|
+
event_object (0.9.4)
|
31
|
+
eventmachine (1.0.7)
|
32
|
+
fibre (0.9.14)
|
33
|
+
event_object (>= 0.9)
|
34
|
+
http_parser.rb (0.6.0)
|
35
|
+
model_pack (0.9.10)
|
36
|
+
util_pack (0.1.0)
|
37
|
+
|
38
|
+
PLATFORMS
|
39
|
+
ruby
|
40
|
+
|
41
|
+
DEPENDENCIES
|
42
|
+
emmy
|
43
|
+
emmy-http-client!
|
data/example/simple.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'emmy'
|
3
|
+
|
4
|
+
Emmy.run_block do
|
5
|
+
request = Emmy::Http.request(
|
6
|
+
type: 'GET',
|
7
|
+
url: 'http://localhost:3003',
|
8
|
+
path: '/ping',
|
9
|
+
timeouts: { connect: 5, inactivity: 20}
|
10
|
+
)
|
11
|
+
|
12
|
+
puts "#{request.type} #{request.real_url}"
|
13
|
+
|
14
|
+
response = request.sync
|
15
|
+
|
16
|
+
puts "RESPONSE #{response.status}"
|
17
|
+
puts response.headers
|
18
|
+
puts response.body
|
19
|
+
end
|
@@ -36,7 +36,6 @@ module EmmyHttp
|
|
36
36
|
|
37
37
|
conn.pending_connect_timeout = request.timeouts.connect
|
38
38
|
conn.comm_inactivity_timeout = request.timeouts.inactivity
|
39
|
-
|
40
39
|
attach(conn)
|
41
40
|
|
42
41
|
parser.on :head do |headers|
|
@@ -71,20 +70,12 @@ module EmmyHttp
|
|
71
70
|
end
|
72
71
|
|
73
72
|
def data(chunk)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
stop(e.message)
|
78
|
-
end
|
73
|
+
parser << chunk
|
74
|
+
rescue EmmyHttp::ParserError => e
|
75
|
+
stop(e.message)
|
79
76
|
end
|
80
77
|
|
81
78
|
def close(reason=nil)
|
82
|
-
if stop_reason
|
83
|
-
change_state(:catch_error)
|
84
|
-
operation.error!(stop_reason)
|
85
|
-
return
|
86
|
-
end
|
87
|
-
|
88
79
|
if state == :body && !response.content_length?
|
89
80
|
response.finish
|
90
81
|
end
|
@@ -94,11 +85,15 @@ module EmmyHttp
|
|
94
85
|
self.url = url + response.location
|
95
86
|
self.response = nil
|
96
87
|
parser.reset!
|
97
|
-
|
88
|
+
begin
|
89
|
+
operation.reconnect
|
90
|
+
rescue EventMachine::ConnectionError => e
|
91
|
+
finalize(e.to_s)
|
92
|
+
end
|
98
93
|
return
|
99
94
|
end
|
100
95
|
|
101
|
-
finalize(reason)
|
96
|
+
finalize(stop_reason || reason)
|
102
97
|
end
|
103
98
|
|
104
99
|
def send_request
|
@@ -143,8 +138,8 @@ module EmmyHttp
|
|
143
138
|
|
144
139
|
elsif json
|
145
140
|
json_string = json.is_a?(String) ? json : (json.respond_to?(:to_json) ? json.to_json : JSON.dump(json))
|
146
|
-
headers['Content-Length'] = json_string.size
|
147
141
|
headers['Content-Type'] = 'application/json'
|
142
|
+
headers['Content-Length'] = json_string.size
|
148
143
|
json_string
|
149
144
|
|
150
145
|
elsif file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emmy-http-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- inre
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http_parser.rb
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '10.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '3'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '3'
|
125
139
|
description: EventMachine-based HTTP request client
|
126
140
|
email:
|
127
141
|
- inre.storm@gmail.com
|
@@ -138,6 +152,9 @@ files:
|
|
138
152
|
- Rakefile
|
139
153
|
- TODO.md
|
140
154
|
- emmy-http-client.gemspec
|
155
|
+
- example/Gemfile
|
156
|
+
- example/Gemfile.lock
|
157
|
+
- example/simple.rb
|
141
158
|
- lib/emmy_http/client.rb
|
142
159
|
- lib/emmy_http/client/adapter.rb
|
143
160
|
- lib/emmy_http/client/client.rb
|
@@ -167,8 +184,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
184
|
version: '0'
|
168
185
|
requirements: []
|
169
186
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.
|
187
|
+
rubygems_version: 2.5.1
|
171
188
|
signing_key:
|
172
189
|
specification_version: 4
|
173
190
|
summary: HTTP request client
|
174
191
|
test_files: []
|
192
|
+
has_rdoc:
|