rack-client 0.3.1.pre.c → 0.3.1.pre.d
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rack/client/adapter/base.rb +0 -1
- data/lib/rack/client/adapter/simple.rb +13 -4
- data/lib/rack/client/version.rb +1 -1
- metadata +80 -108
- data/spec/core/headers_spec.rb +0 -47
- data/spec/core/headers_spec.rbc +0 -1674
- data/spec/core/response_spec.rb +0 -78
- data/spec/core/response_spec.rbc +0 -2244
- data/spec/handler/em_http_spec.rb +0 -7
- data/spec/handler/em_http_spec.rbc +0 -224
- data/spec/handler/excon_spec.rb +0 -7
- data/spec/handler/excon_spec.rbc +0 -224
- data/spec/handler/net_http_spec.rb +0 -11
- data/spec/handler/net_http_spec.rbc +0 -307
- data/spec/handler/typhoeus_spec.rb +0 -11
- data/spec/handler/typhoeus_spec.rbc +0 -307
- data/spec/helpers/async_helper.rb +0 -31
- data/spec/helpers/async_helper.rbc +0 -843
- data/spec/helpers/em_http_helper.rb +0 -24
- data/spec/helpers/em_http_helper.rbc +0 -663
- data/spec/helpers/excon_helper.rb +0 -13
- data/spec/helpers/excon_helper.rbc +0 -461
- data/spec/helpers/handler_helper.rb +0 -68
- data/spec/helpers/handler_helper.rbc +0 -1769
- data/spec/helpers/net_http_helper.rb +0 -26
- data/spec/helpers/net_http_helper.rbc +0 -806
- data/spec/helpers/sync_helper.rb +0 -9
- data/spec/helpers/sync_helper.rbc +0 -311
- data/spec/helpers/typhoeus_helper.rb +0 -32
- data/spec/helpers/typhoeus_helper.rbc +0 -936
- data/spec/middleware/cache_spec.rb +0 -25
- data/spec/middleware/cache_spec.rbc +0 -712
- data/spec/middleware/cookie_jar_spec.rb +0 -19
- data/spec/middleware/cookie_jar_spec.rbc +0 -614
- data/spec/middleware/etag_spec.rb +0 -10
- data/spec/middleware/etag_spec.rbc +0 -438
- data/spec/middleware/follow_redirects_spec.rb +0 -12
- data/spec/middleware/follow_redirects_spec.rbc +0 -402
- data/spec/middleware/lint_spec.rb +0 -10
- data/spec/middleware/lint_spec.rbc +0 -392
- data/spec/shared/handler_api.rb +0 -33
- data/spec/shared/handler_api.rbc +0 -1340
- data/spec/shared/streamed_response_api.rb +0 -14
- data/spec/shared/streamed_response_api.rbc +0 -508
- data/spec/spec_apps/cache.ru +0 -14
- data/spec/spec_apps/cookie.ru +0 -12
- data/spec/spec_apps/delete.ru +0 -10
- data/spec/spec_apps/get.ru +0 -13
- data/spec/spec_apps/head.ru +0 -10
- data/spec/spec_apps/hello_world.ru +0 -1
- data/spec/spec_apps/redirect.ru +0 -13
- data/spec/spec_apps/stream.ru +0 -9
- data/spec/spec_config.ru +0 -10
- data/spec/spec_helper.rb +0 -22
@@ -57,14 +57,14 @@ module Rack
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
|
60
61
|
def request_tuple(url, headers = {}, body_or_params = nil, query_params = {}, &block)
|
61
|
-
|
62
|
-
query_hash = Hash === query_or_params ? query_or_params : Utils.build_query(query_or_params)
|
62
|
+
query_hash = Hash === query_params ? query_params : Utils.build_query(query_params)
|
63
63
|
|
64
64
|
uri = URI.parse(url)
|
65
65
|
|
66
66
|
unless query_params.empty?
|
67
|
-
uri.query = Utils.build_nested_query(Utils.parse_nested_query(uri.query).merge(
|
67
|
+
uri.query = Utils.build_nested_query(Utils.parse_nested_query(uri.query).merge(query_params))
|
68
68
|
end
|
69
69
|
|
70
70
|
body = Hash === body_or_params ? Utils.build_nested_query(body_or_params) : body_or_params
|
@@ -74,8 +74,17 @@ module Rack
|
|
74
74
|
|
75
75
|
def build_env(request_method, url, headers = {}, body = nil)
|
76
76
|
uri = @base_uri.nil? ? URI.parse(url) : @base_uri + url
|
77
|
-
super(request_method, uri.to_s, headers, body)
|
77
|
+
{'HTTP_HOST' => http_host_for(uri)}.merge(super(request_method, uri.to_s, headers, body))
|
78
|
+
end
|
79
|
+
|
80
|
+
def http_host_for(uri)
|
81
|
+
unless uri.to_s.include?(":#{uri.port}")
|
82
|
+
[uri.host, uri.port].join(':')
|
83
|
+
else
|
84
|
+
uri.host
|
85
|
+
end
|
78
86
|
end
|
87
|
+
|
79
88
|
end
|
80
89
|
end
|
81
90
|
end
|
data/lib/rack/client/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1923832055
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
9
|
- 1
|
10
10
|
- pre
|
11
|
-
-
|
12
|
-
version: 0.3.1.pre.
|
11
|
+
- d
|
12
|
+
version: 0.3.1.pre.d
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Tim Carey-Smith
|
@@ -17,10 +17,81 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-
|
20
|
+
date: 2010-11-09 00:00:00 -08:00
|
21
21
|
default_executable:
|
22
|
-
dependencies:
|
23
|
-
|
22
|
+
dependencies:
|
23
|
+
- !ruby/object:Gem::Dependency
|
24
|
+
name: rack
|
25
|
+
prerelease: false
|
26
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
hash: 23
|
32
|
+
segments:
|
33
|
+
- 1
|
34
|
+
- 0
|
35
|
+
- 0
|
36
|
+
version: 1.0.0
|
37
|
+
type: :runtime
|
38
|
+
version_requirements: *id001
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: excon
|
41
|
+
prerelease: false
|
42
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
hash: 3
|
48
|
+
segments:
|
49
|
+
- 0
|
50
|
+
version: "0"
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: em-http-request
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: typhoeus
|
69
|
+
prerelease: false
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
type: :development
|
80
|
+
version_requirements: *id004
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: json
|
83
|
+
prerelease: false
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 3
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
|
+
type: :development
|
94
|
+
version_requirements: *id005
|
24
95
|
description: A client wrapper around a Rack app or HTTP
|
25
96
|
email: tim@spork.in
|
26
97
|
executables: []
|
@@ -134,56 +205,6 @@ files:
|
|
134
205
|
- demo/config.ru
|
135
206
|
- demo/demo.rb
|
136
207
|
- demo/demo_spec.rb
|
137
|
-
- spec/core/headers_spec.rb
|
138
|
-
- spec/core/headers_spec.rbc
|
139
|
-
- spec/core/response_spec.rb
|
140
|
-
- spec/core/response_spec.rbc
|
141
|
-
- spec/handler/em_http_spec.rb
|
142
|
-
- spec/handler/em_http_spec.rbc
|
143
|
-
- spec/handler/excon_spec.rb
|
144
|
-
- spec/handler/excon_spec.rbc
|
145
|
-
- spec/handler/net_http_spec.rb
|
146
|
-
- spec/handler/net_http_spec.rbc
|
147
|
-
- spec/handler/typhoeus_spec.rb
|
148
|
-
- spec/handler/typhoeus_spec.rbc
|
149
|
-
- spec/helpers/async_helper.rb
|
150
|
-
- spec/helpers/async_helper.rbc
|
151
|
-
- spec/helpers/em_http_helper.rb
|
152
|
-
- spec/helpers/em_http_helper.rbc
|
153
|
-
- spec/helpers/excon_helper.rb
|
154
|
-
- spec/helpers/excon_helper.rbc
|
155
|
-
- spec/helpers/handler_helper.rb
|
156
|
-
- spec/helpers/handler_helper.rbc
|
157
|
-
- spec/helpers/net_http_helper.rb
|
158
|
-
- spec/helpers/net_http_helper.rbc
|
159
|
-
- spec/helpers/sync_helper.rb
|
160
|
-
- spec/helpers/sync_helper.rbc
|
161
|
-
- spec/helpers/typhoeus_helper.rb
|
162
|
-
- spec/helpers/typhoeus_helper.rbc
|
163
|
-
- spec/middleware/cache_spec.rb
|
164
|
-
- spec/middleware/cache_spec.rbc
|
165
|
-
- spec/middleware/cookie_jar_spec.rb
|
166
|
-
- spec/middleware/cookie_jar_spec.rbc
|
167
|
-
- spec/middleware/etag_spec.rb
|
168
|
-
- spec/middleware/etag_spec.rbc
|
169
|
-
- spec/middleware/follow_redirects_spec.rb
|
170
|
-
- spec/middleware/follow_redirects_spec.rbc
|
171
|
-
- spec/middleware/lint_spec.rb
|
172
|
-
- spec/middleware/lint_spec.rbc
|
173
|
-
- spec/shared/handler_api.rb
|
174
|
-
- spec/shared/handler_api.rbc
|
175
|
-
- spec/shared/streamed_response_api.rb
|
176
|
-
- spec/shared/streamed_response_api.rbc
|
177
|
-
- spec/spec_apps/cache.ru
|
178
|
-
- spec/spec_apps/cookie.ru
|
179
|
-
- spec/spec_apps/delete.ru
|
180
|
-
- spec/spec_apps/get.ru
|
181
|
-
- spec/spec_apps/head.ru
|
182
|
-
- spec/spec_apps/hello_world.ru
|
183
|
-
- spec/spec_apps/redirect.ru
|
184
|
-
- spec/spec_apps/stream.ru
|
185
|
-
- spec/spec_config.ru
|
186
|
-
- spec/spec_helper.rb
|
187
208
|
has_rdoc: true
|
188
209
|
homepage: http://github.com/halorgium/rack-client
|
189
210
|
licenses: []
|
@@ -215,59 +236,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
236
|
version: 1.3.1
|
216
237
|
requirements: []
|
217
238
|
|
218
|
-
rubyforge_project:
|
239
|
+
rubyforge_project:
|
219
240
|
rubygems_version: 1.3.7
|
220
241
|
signing_key:
|
221
242
|
specification_version: 3
|
222
243
|
summary: A client wrapper around a Rack app or HTTP
|
223
|
-
test_files:
|
224
|
-
|
225
|
-
- spec/core/headers_spec.rbc
|
226
|
-
- spec/core/response_spec.rb
|
227
|
-
- spec/core/response_spec.rbc
|
228
|
-
- spec/handler/em_http_spec.rb
|
229
|
-
- spec/handler/em_http_spec.rbc
|
230
|
-
- spec/handler/excon_spec.rb
|
231
|
-
- spec/handler/excon_spec.rbc
|
232
|
-
- spec/handler/net_http_spec.rb
|
233
|
-
- spec/handler/net_http_spec.rbc
|
234
|
-
- spec/handler/typhoeus_spec.rb
|
235
|
-
- spec/handler/typhoeus_spec.rbc
|
236
|
-
- spec/helpers/async_helper.rb
|
237
|
-
- spec/helpers/async_helper.rbc
|
238
|
-
- spec/helpers/em_http_helper.rb
|
239
|
-
- spec/helpers/em_http_helper.rbc
|
240
|
-
- spec/helpers/excon_helper.rb
|
241
|
-
- spec/helpers/excon_helper.rbc
|
242
|
-
- spec/helpers/handler_helper.rb
|
243
|
-
- spec/helpers/handler_helper.rbc
|
244
|
-
- spec/helpers/net_http_helper.rb
|
245
|
-
- spec/helpers/net_http_helper.rbc
|
246
|
-
- spec/helpers/sync_helper.rb
|
247
|
-
- spec/helpers/sync_helper.rbc
|
248
|
-
- spec/helpers/typhoeus_helper.rb
|
249
|
-
- spec/helpers/typhoeus_helper.rbc
|
250
|
-
- spec/middleware/cache_spec.rb
|
251
|
-
- spec/middleware/cache_spec.rbc
|
252
|
-
- spec/middleware/cookie_jar_spec.rb
|
253
|
-
- spec/middleware/cookie_jar_spec.rbc
|
254
|
-
- spec/middleware/etag_spec.rb
|
255
|
-
- spec/middleware/etag_spec.rbc
|
256
|
-
- spec/middleware/follow_redirects_spec.rb
|
257
|
-
- spec/middleware/follow_redirects_spec.rbc
|
258
|
-
- spec/middleware/lint_spec.rb
|
259
|
-
- spec/middleware/lint_spec.rbc
|
260
|
-
- spec/shared/handler_api.rb
|
261
|
-
- spec/shared/handler_api.rbc
|
262
|
-
- spec/shared/streamed_response_api.rb
|
263
|
-
- spec/shared/streamed_response_api.rbc
|
264
|
-
- spec/spec_apps/cache.ru
|
265
|
-
- spec/spec_apps/cookie.ru
|
266
|
-
- spec/spec_apps/delete.ru
|
267
|
-
- spec/spec_apps/get.ru
|
268
|
-
- spec/spec_apps/head.ru
|
269
|
-
- spec/spec_apps/hello_world.ru
|
270
|
-
- spec/spec_apps/redirect.ru
|
271
|
-
- spec/spec_apps/stream.ru
|
272
|
-
- spec/spec_config.ru
|
273
|
-
- spec/spec_helper.rb
|
244
|
+
test_files: []
|
245
|
+
|
data/spec/core/headers_spec.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Rack::Client::Headers do
|
4
|
-
context ".from" do
|
5
|
-
it 'rejects headers which do not do not start with HTTP_, excluding CONTENT_TYPE and CONTENT_LENGTH' do
|
6
|
-
headers = Rack::Client::Headers.from('rack.foo' => 'bar',
|
7
|
-
'HTTP_X_RACK_FOO' => 'bar',
|
8
|
-
'CONTENT_TYPE' => 'text/plain',
|
9
|
-
'CONTENT_LENGTH' => 100)
|
10
|
-
headers['rack.foo'].should be_nil
|
11
|
-
headers['HTTP_X_RACK_FOO'].should == 'bar'
|
12
|
-
headers['CONTENT_TYPE'].should == 'text/plain'
|
13
|
-
headers['CONTENT_LENGTH'].should == 100
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context "#initialize" do
|
18
|
-
it 'merges in any arguments' do
|
19
|
-
Rack::Client::Headers.new('HTTP_X_RACK_FOO' => 'bar')['HTTP_X_RACK_FOO'] = 'bar'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context "#to_http" do
|
24
|
-
it 'removes the leading "HTTP_" from headers' do
|
25
|
-
headers = Rack::Client::Headers.new('HTTP_X_RACK_FOO' => 'bar').to_http
|
26
|
-
headers.keys.detect {|header| header =~ /^HTTP_/ }.should be_nil
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'Titleizes the header name' do
|
30
|
-
headers = Rack::Client::Headers.new('HTTP_X_RACK_FOO' => 'bar').to_http
|
31
|
-
headers['X-Rack-Foo'].should == 'bar'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "#to_env" do
|
36
|
-
it 'rackifies http header names, except CONTENT_TYPE and CONTENT_LENGTH' do
|
37
|
-
headers = Rack::Client::Headers.new('rack.foo' => 'bar',
|
38
|
-
'X-Rack-Foo' => 'bar',
|
39
|
-
'CONTENT_TYPE' => 'text/plain',
|
40
|
-
'CONTENT_LENGTH' => 100).to_env
|
41
|
-
|
42
|
-
headers['HTTP_X_RACK_FOO'].should == 'bar'
|
43
|
-
headers['CONTENT_TYPE'].should == 'text/plain'
|
44
|
-
headers['CONTENT_LENGTH'].should == 100
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|