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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1dd34d36113e5aeb7a5126f1f6e38c254316cf3f
4
- data.tar.gz: 81eab83c979cefcb30e81139d25675f5b0a31ef7
3
+ metadata.gz: d9db9a533cd4003a5226ef344b853e5829f11a7d
4
+ data.tar.gz: 509e88d84a3216dadccf4f59587ae172a22b90e5
5
5
  SHA512:
6
- metadata.gz: 9bd07609f837a893ac5f8b2b7df36a42042fe6daceb92cd5fc9cede78445856be961643515de80f410105934de63b5b7f0070775df9199c4b1e958e718a1833a
7
- data.tar.gz: 4a0b10b1bb16ea62c8e267ea836ae87ed897266fef2751b5ca36545891ac19bfe0fc8a1e6e3926e96d1b07c718c1c03aa5ab2a1ba29ef8c4002879b82041e367
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, service_url(url), service_params(params),
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
 
@@ -151,14 +151,13 @@ module Pebblebed
151
151
  end
152
152
  end
153
153
 
154
- def self.stream_get(url = nil, params = nil, options = {})
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, options = {})
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,
@@ -1,3 +1,3 @@
1
1
  module Pebblebed
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
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.6
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-04-06 00:00:00.000000000 Z
12
+ date: 2018-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec