lhc 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhc/request.rb +7 -1
- data/lib/lhc/version.rb +1 -1
- data/spec/request/encoding_spec.rb +24 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82137985f03859481eb4bc258f9364d2b1dcde53
|
4
|
+
data.tar.gz: 6b3508329130153d2a84fbb09012c9c2caf3ff45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f32f740fddfa2a5e125eccafc883c12e55e88998660a929a073941d2019cfa9aed93cb36eafbd9b679b77c2838d9958ff4d9c2cc95cfc43cb1e5de4d820f291a
|
7
|
+
data.tar.gz: 4c4460d6c257868887b22c13f4f53c3d37e6c9137007eeff2c8d668debcf00179cd576d218d8b7fa52bb0e2634901d821f4053073c7a368e012dc0d6026eb220
|
data/lib/lhc/request.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'typhoeus'
|
2
|
+
require 'uri'
|
2
3
|
require 'active_support/core_ext/object/deep_dup'
|
3
4
|
|
4
5
|
# The request is doing an http-request using typhoeus.
|
@@ -41,7 +42,7 @@ class LHC::Request
|
|
41
42
|
attr_accessor :iprocessor
|
42
43
|
|
43
44
|
def create_request
|
44
|
-
request = Typhoeus::Request.new(options[:url], typhoeusize(options))
|
45
|
+
request = Typhoeus::Request.new(encode_url(options[:url]), typhoeusize(options))
|
45
46
|
request.on_headers do
|
46
47
|
iprocessor.intercept(:after_request, self)
|
47
48
|
iprocessor.intercept(:before_response, self)
|
@@ -50,6 +51,11 @@ class LHC::Request
|
|
50
51
|
request
|
51
52
|
end
|
52
53
|
|
54
|
+
def encode_url(url)
|
55
|
+
return url if url.nil?
|
56
|
+
URI.escape(url)
|
57
|
+
end
|
58
|
+
|
53
59
|
def typhoeusize(options)
|
54
60
|
options = options.deep_dup
|
55
61
|
easy = Ethon::Easy.new
|
data/lib/lhc/version.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe LHC::Request do
|
4
|
+
|
5
|
+
context 'encoding url' do
|
6
|
+
|
7
|
+
let(:url) { 'http://local.ch/something with spaces' }
|
8
|
+
|
9
|
+
it 'can request urls with spaces inside' do
|
10
|
+
stub_request(:get, URI::encode(url))
|
11
|
+
LHC.get(url)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'encoding params' do
|
16
|
+
|
17
|
+
let(:url) { 'http://local.ch/api/search?name=:name' }
|
18
|
+
|
19
|
+
it 'can do requests with params including spaces' do
|
20
|
+
stub_request(:get, 'http://local.ch/api/search?name=My%20name%20is%20rabbit')
|
21
|
+
LHC.get(url, params: { name: 'My name is rabbit' })
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- local.ch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -204,6 +204,7 @@ files:
|
|
204
204
|
- spec/interceptors/response_competition_spec.rb
|
205
205
|
- spec/interceptors/return_response_spec.rb
|
206
206
|
- spec/rails_helper.rb
|
207
|
+
- spec/request/encoding_spec.rb
|
207
208
|
- spec/request/error_handling_spec.rb
|
208
209
|
- spec/request/headers_spec.rb
|
209
210
|
- spec/request/option_dup_spec.rb
|
@@ -311,6 +312,7 @@ test_files:
|
|
311
312
|
- spec/interceptors/response_competition_spec.rb
|
312
313
|
- spec/interceptors/return_response_spec.rb
|
313
314
|
- spec/rails_helper.rb
|
315
|
+
- spec/request/encoding_spec.rb
|
314
316
|
- spec/request/error_handling_spec.rb
|
315
317
|
- spec/request/headers_spec.rb
|
316
318
|
- spec/request/option_dup_spec.rb
|