pebblebed 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pebblebed/clients/generic_client.rb +9 -1
- data/lib/pebblebed/http.rb +5 -8
- data/lib/pebblebed/version.rb +1 -1
- data/spec/http_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9db9a533cd4003a5226ef344b853e5829f11a7d
|
4
|
+
data.tar.gz: 509e88d84a3216dadccf4f59587ae172a22b90e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 331dab24969bf78c97e848e6b5959fe848606c557fe6331df85043aed19ae7469d52aad70e121c69347d28f321c97b60826e917091e3f3a515c88c35e8436f39
|
7
|
+
data.tar.gz: 61bb3e6482904ff6bda0f3a6f2cb176182d4d11a25c0529a0d8ed664025ec434d8e1b1278b472b616ad2b499e894f72a86ae5ef864007ac606ae0dff7f0bd089
|
@@ -27,9 +27,16 @@ module Pebblebed
|
|
27
27
|
method_name = "stream_#{method.to_s.downcase}"
|
28
28
|
raise "Method not supported for streaming" unless Pebblebed::Http.respond_to?(method_name)
|
29
29
|
|
30
|
+
headers = {}
|
31
|
+
if accept
|
32
|
+
headers['Accept'] = accept
|
33
|
+
end
|
34
|
+
|
30
35
|
if accept == 'application/x-ndjson'
|
31
36
|
buffer = NdjsonBuffer.new(on_data)
|
32
|
-
response = Pebblebed::Http.send(method_name,
|
37
|
+
response = Pebblebed::Http.send(method_name,
|
38
|
+
service_url(url), service_params(params),
|
39
|
+
headers: headers,
|
33
40
|
on_data: ->(data) {
|
34
41
|
buffer << data
|
35
42
|
})
|
@@ -38,6 +45,7 @@ module Pebblebed
|
|
38
45
|
end
|
39
46
|
|
40
47
|
return Pebblebed::Http.send(method_name, service_url(url), service_params(params),
|
48
|
+
headers: headers,
|
41
49
|
on_data: on_data)
|
42
50
|
end
|
43
51
|
|
data/lib/pebblebed/http.rb
CHANGED
@@ -151,14 +151,13 @@ module Pebblebed
|
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
154
|
-
def self.stream_get(url = nil, params = nil,
|
155
|
-
on_data = options[:on_data] or raise "Option :on_data must be specified"
|
156
|
-
|
154
|
+
def self.stream_get(url = nil, params = nil, headers: {}, on_data:)
|
157
155
|
url, params, query = url_and_params_from_args(url, params)
|
158
156
|
return do_request(url) { |connection|
|
159
157
|
connection.get(
|
160
158
|
:host => url.host,
|
161
159
|
:path => url.path,
|
160
|
+
:headers => headers,
|
162
161
|
:query => QueryParams.encode((params || {}).merge(query)),
|
163
162
|
:persistent => false,
|
164
163
|
:response_block => streamer(on_data)
|
@@ -166,9 +165,7 @@ module Pebblebed
|
|
166
165
|
}
|
167
166
|
end
|
168
167
|
|
169
|
-
def self.stream_post(url, params,
|
170
|
-
on_data = options[:on_data] or raise "Option :on_data must be specified"
|
171
|
-
|
168
|
+
def self.stream_post(url, params, headers: {}, on_data:)
|
172
169
|
url, params, query = url_and_params_from_args(url, params)
|
173
170
|
content_type, body = serialize_params(params)
|
174
171
|
|
@@ -179,7 +176,7 @@ module Pebblebed
|
|
179
176
|
:headers => {
|
180
177
|
'Accept' => 'application/json',
|
181
178
|
'Content-Type' => content_type
|
182
|
-
},
|
179
|
+
}.merge(headers),
|
183
180
|
:body => body,
|
184
181
|
:persistent => false,
|
185
182
|
:query => query,
|
@@ -201,7 +198,7 @@ module Pebblebed
|
|
201
198
|
:headers => {
|
202
199
|
'Accept' => 'application/json',
|
203
200
|
'Content-Type' => content_type
|
204
|
-
},
|
201
|
+
}.merge(headers),
|
205
202
|
:body => body,
|
206
203
|
:query => query,
|
207
204
|
:persistent => false,
|
data/lib/pebblebed/version.rb
CHANGED
data/spec/http_spec.rb
CHANGED
@@ -124,8 +124,20 @@ describe Pebblebed::Http do
|
|
124
124
|
expect(response.body).to eq ''
|
125
125
|
end
|
126
126
|
end
|
127
|
+
|
128
|
+
it "sends headers" do
|
129
|
+
Excon.stub({:method => :get}) { |params|
|
130
|
+
expect(params[:headers]['Accept']).to eq 'application/x-ndjson'
|
131
|
+
{body: '', headers: {}, status: 200}
|
132
|
+
}
|
133
|
+
|
134
|
+
Pebblebed::Http.stream_get("http://example.org/", {},
|
135
|
+
headers: {'Accept' => 'application/x-ndjson'},
|
136
|
+
on_data: ->() {})
|
137
|
+
end
|
127
138
|
end
|
128
139
|
end
|
140
|
+
|
129
141
|
it "enforces read timeout" do
|
130
142
|
Pebblebed::Http.read_timeout = 1
|
131
143
|
expect {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pebblebed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katrina Owen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-05-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|