songkick-transport 1.9.0 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/songkick/transport/curb.rb +8 -2
- data/spec/songkick/transport/curb_spec.rb +12 -1
- data/spec/songkick/transport/httparty_spec.rb +21 -3
- data/spec/spec_helper.rb +5 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fe0da63a4b8a2922d2e54f19b00e65dd5fa7abe
|
4
|
+
data.tar.gz: 58a16dd55c6c201209beea4381935e61d8ad7f26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6786e9954745bb68d84a8509e6fa9cf2cbd090e4d9c66c0ed27136b1bda2abb7d630ff2b81006f4f473025b28e58232df6524989b23259f6e658b628e65bdb5e
|
7
|
+
data.tar.gz: 540c662c5c7683f2a62b6940a43cad2c0650674957ae6fb9157d520ade72b31a3d4df9111554b0ebc58716bb39d3bf26c65ecb1b31071572481842c66db4896a
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'cgi'
|
2
|
-
|
2
|
+
|
3
|
+
autoload :Curl, 'curb'
|
3
4
|
|
4
5
|
module Songkick
|
5
6
|
module Transport
|
@@ -50,7 +51,12 @@ module Songkick
|
|
50
51
|
line = header_line.sub(/\r\n$/, '')
|
51
52
|
parts = line.split(/:\s*/)
|
52
53
|
if parts.size >= 2
|
53
|
-
|
54
|
+
header_name, value = parts.shift, parts * ':'
|
55
|
+
if response_headers[header_name]
|
56
|
+
response_headers[header_name] << ", #{value}"
|
57
|
+
else
|
58
|
+
response_headers[header_name] = value
|
59
|
+
end
|
54
60
|
end
|
55
61
|
header_line.bytesize
|
56
62
|
end
|
@@ -25,13 +25,24 @@ module Songkick
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
describe
|
28
|
+
describe 'handling errors' do
|
29
29
|
when_request_raises_the_exception(Curl::Err::HostResolutionError) { it_should_raise(Transport::HostResolutionError) }
|
30
30
|
when_request_raises_the_exception(Curl::Err::ConnectionFailedError) { it_should_raise(Transport::ConnectionFailedError) }
|
31
31
|
when_request_raises_the_exception(Curl::Err::TimeoutError) { it_should_raise(Transport::TimeoutError) }
|
32
32
|
when_request_raises_the_exception(Curl::Err::GotNothingError) { it_should_raise(Transport::UpstreamError) }
|
33
33
|
when_request_raises_the_exception(Curl::Err::RecvError) { it_should_raise(Transport::UpstreamError) }
|
34
34
|
end
|
35
|
+
|
36
|
+
describe 'headers parsing' do
|
37
|
+
let(:curl) { instance_double(Curl::Easy, :response_code => 200, :headers => {}).as_null_object }
|
38
|
+
|
39
|
+
it 'should join multiple headers to one' do
|
40
|
+
allow(curl).to receive(:on_header).and_yield('Set-Cookie: a').and_yield('Set-Cookie: b')
|
41
|
+
|
42
|
+
response = subject.execute_request(request)
|
43
|
+
expect(response.headers['Set-Cookie']).to eq 'a, b'
|
44
|
+
end
|
45
|
+
end
|
35
46
|
end
|
36
47
|
|
37
48
|
end
|
@@ -8,14 +8,14 @@ module Songkick
|
|
8
8
|
|
9
9
|
let(:request){ Request.new('http://localhost', 'get', '/', {}) }
|
10
10
|
|
11
|
-
describe
|
11
|
+
describe 'handling errors' do
|
12
12
|
class FakeHttparty < Songkick::Transport::HttParty::Adapter
|
13
13
|
class << self
|
14
14
|
attr_accessor :error
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.get(path, args)
|
18
|
-
raise(error,
|
18
|
+
raise(error, 'bang') if error
|
19
19
|
end
|
20
20
|
|
21
21
|
end
|
@@ -41,13 +41,31 @@ module Songkick
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
describe
|
44
|
+
describe 'handling errors' do
|
45
45
|
when_request_raises_the_exception(FakeJSONException) { it_should_raise(Transport::InvalidJSONError) }
|
46
46
|
when_request_raises_the_exception(SocketError) { it_should_raise(Transport::ConnectionFailedError) }
|
47
47
|
when_request_raises_the_exception(Timeout::Error) { it_should_raise(Transport::TimeoutError) }
|
48
48
|
when_request_raises_the_exception(UpstreamError) { it_should_raise(Transport::UpstreamError) }
|
49
49
|
when_request_raises_the_exception(Exception) { it_should_raise(Transport::UpstreamError) }
|
50
50
|
end
|
51
|
+
|
52
|
+
describe 'headers parsing' do
|
53
|
+
let(:httparty) { Songkick::Transport::HttParty.new('localhost') }
|
54
|
+
let(:request) { Request.new('http://localhost:4567', 'get', '/with_headers', {}) }
|
55
|
+
|
56
|
+
before do
|
57
|
+
TestApp.listen(4567)
|
58
|
+
end
|
59
|
+
|
60
|
+
after do
|
61
|
+
TestApp.stop
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should join multiple headers to one' do
|
65
|
+
response = httparty.execute_request(request)
|
66
|
+
expect(response.headers['Set-Cookie']).to eq 'a, b'
|
67
|
+
end
|
68
|
+
end
|
51
69
|
end
|
52
70
|
end
|
53
71
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: songkick-transport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Lucraft
|
@@ -10,10 +10,11 @@ authors:
|
|
10
10
|
- Robin Tweedie
|
11
11
|
- Paul Lawson
|
12
12
|
- Sabina Bejasa-Dimmock
|
13
|
+
- Paul Springett
|
13
14
|
autorequire:
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
|
-
date: 2015-
|
17
|
+
date: 2015-10-28 00:00:00.000000000 Z
|
17
18
|
dependencies:
|
18
19
|
- !ruby/object:Gem::Dependency
|
19
20
|
name: multipart-post
|
@@ -77,14 +78,14 @@ dependencies:
|
|
77
78
|
requirements:
|
78
79
|
- - ">="
|
79
80
|
- !ruby/object:Gem::Version
|
80
|
-
version: 0.
|
81
|
+
version: 0.8.0
|
81
82
|
type: :development
|
82
83
|
prerelease: false
|
83
84
|
version_requirements: !ruby/object:Gem::Requirement
|
84
85
|
requirements:
|
85
86
|
- - ">="
|
86
87
|
- !ruby/object:Gem::Version
|
87
|
-
version: 0.
|
88
|
+
version: 0.8.0
|
88
89
|
- !ruby/object:Gem::Dependency
|
89
90
|
name: rack-test
|
90
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,3 +220,4 @@ signing_key:
|
|
219
220
|
specification_version: 4
|
220
221
|
summary: HTTP client abstraction for service clients
|
221
222
|
test_files: []
|
223
|
+
has_rdoc:
|