em-http-request 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of em-http-request might be problematic. Click here for more details.

@@ -1,24 +1,24 @@
1
- require 'helper'
2
-
3
- requires_connection do
4
- requires_port(8080) do
5
- describe EventMachine::HttpRequest do
6
-
7
- # ssh -D 8080 igvita
8
- let(:proxy) { {:proxy => { :host => '127.0.0.1', :port => 8080, :type => :socks5 }} }
9
-
10
- it "should use SOCKS5 proxy" do
11
- EventMachine.run {
12
- http = EventMachine::HttpRequest.new('http://jsonip.com/', proxy).get
13
-
14
- http.errback { failed(http) }
15
- http.callback {
16
- http.response_header.status.should == 200
17
- http.response.should match('173.230.151.99')
18
- EventMachine.stop
19
- }
20
- }
21
- end
22
- end
23
- end
24
- end
1
+ require 'helper'
2
+
3
+ requires_connection do
4
+ requires_port(8080) do
5
+ describe EventMachine::HttpRequest do
6
+
7
+ # ssh -D 8080 igvita
8
+ let(:proxy) { {:proxy => { :host => '127.0.0.1', :port => 8080, :type => :socks5 }} }
9
+
10
+ it "should use SOCKS5 proxy" do
11
+ EventMachine.run {
12
+ http = EventMachine::HttpRequest.new('http://jsonip.com/', proxy).get
13
+
14
+ http.errback { failed(http) }
15
+ http.callback {
16
+ http.response_header.status.should == 200
17
+ http.response.should match('173.230.151.99')
18
+ EventMachine.stop
19
+ }
20
+ }
21
+ end
22
+ end
23
+ end
24
+ end
@@ -85,12 +85,17 @@ Stallion.saddle :spec do |stable|
85
85
  stable.response["Last-Modified"] = "Fri, 13 Aug 2010 17:31:21 GMT"
86
86
  stable.response.write stable.request.query_string
87
87
 
88
+ elsif stable.request.path_info == '/echo_headers'
89
+ stable.response["Set-Cookie"] = "test=yes"
90
+ stable.response["X-Forward-Host"] = "proxy.local"
91
+ stable.response.write stable.request.query_string
92
+
88
93
  elsif stable.request.path_info == '/echo_content_length'
89
94
  stable.response.write stable.request.content_length
90
95
 
91
96
  elsif stable.request.path_info == '/echo_content_length_from_header'
92
97
  stable.response.write "content-length:#{stable.request.env["CONTENT_LENGTH"]}"
93
-
98
+
94
99
  elsif stable.request.head? && stable.request.path_info == '/'
95
100
  stable.response.status = 200
96
101
 
@@ -100,7 +105,7 @@ Stallion.saddle :spec do |stable|
100
105
  elsif stable.request.put?
101
106
  stable.response.write stable.request.body.read
102
107
 
103
- elsif stable.request.post?
108
+ elsif stable.request.post? || stable.request.patch?
104
109
  if stable.request.path_info == '/echo_content_type'
105
110
  stable.response["Content-Type"] = stable.request.env["CONTENT_TYPE"] || 'text/html'
106
111
  stable.response.write stable.request.env["CONTENT_TYPE"]
@@ -145,6 +150,10 @@ Stallion.saddle :spec do |stable|
145
150
  stable.response.status = 301
146
151
  stable.response["Location"] = "http://127.0.0.1:8090"
147
152
 
153
+ elsif stable.request.path_info == '/redirect/timeout'
154
+ stable.response.status = 301
155
+ stable.response["Location"] = "http://127.0.0.1:8090/timeout"
156
+
148
157
  elsif stable.request.path_info == '/redirect/head'
149
158
  stable.response.status = 301
150
159
  stable.response["Location"] = "/"
@@ -180,6 +189,12 @@ Stallion.saddle :spec do |stable|
180
189
  stable.response.write io.string
181
190
  stable.response["Content-Encoding"] = "gzip"
182
191
 
192
+ elsif stable.request.path_info == '/gzip-large'
193
+ contents = File.open(File.dirname(__FILE__) + "/fixtures/gzip-sample.gz", 'r') { |f| f.read }
194
+
195
+ stable.response.write contents
196
+ stable.response["Content-Encoding"] = "gzip"
197
+
183
198
  elsif stable.request.path_info == '/deflate'
184
199
  deflater = Zlib::Deflate.new(
185
200
  Zlib::DEFAULT_COMPRESSION,
@@ -237,6 +252,7 @@ Thread.new do
237
252
  end
238
253
  parts = request.split("\r\n")
239
254
  method, destination, http_version = parts.first.split(' ')
255
+ proxy = parts.find { |part| part =~ /Proxy-Authorization/ }
240
256
  if destination =~ /^http:/
241
257
  uri = Addressable::URI.parse(destination)
242
258
  absolute_path = uri.path + (uri.query ? "?#{uri.query}" : "")
@@ -253,7 +269,11 @@ Thread.new do
253
269
 
254
270
  # Take the initial line from the upstream response
255
271
  session.write client.gets
256
-
272
+
273
+ if proxy
274
+ session.write "X-Proxy-Auth: #{proxy}\r\n"
275
+ end
276
+
257
277
  # What (absolute) uri was requested? Send it back in a header
258
278
  session.write "X-The-Requested-URI: #{destination}\r\n"
259
279
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-http-request
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-13 00:00:00.000000000 Z
12
+ date: 2012-08-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
16
- requirement: &2151933100 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 1.0.0.beta.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2151933100
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.0.beta.4
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: addressable
27
- requirement: &2151932120 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 2.2.3
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *2151932120
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 2.2.3
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: http_parser.rb
38
- requirement: &2151930940 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 0.5.3
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *2151930940
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.5.3
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: em-socksify
49
- requirement: &2151926640 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '0'
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *2151926640
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: cookiejar
60
- requirement: &2151918420 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ! '>='
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '0'
66
86
  type: :runtime
67
87
  prerelease: false
68
- version_requirements: *2151918420
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: rspec
71
- requirement: &2151912040 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ! '>='
@@ -76,10 +101,15 @@ dependencies:
76
101
  version: '0'
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *2151912040
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: rake
82
- requirement: &2151906000 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ! '>='
@@ -87,10 +117,15 @@ dependencies:
87
117
  version: '0'
88
118
  type: :development
89
119
  prerelease: false
90
- version_requirements: *2151906000
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
91
126
  - !ruby/object:Gem::Dependency
92
127
  name: rack
93
- requirement: &2151903020 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
94
129
  none: false
95
130
  requirements:
96
131
  - - ! '>='
@@ -98,10 +133,15 @@ dependencies:
98
133
  version: '0'
99
134
  type: :development
100
135
  prerelease: false
101
- version_requirements: *2151903020
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
102
142
  - !ruby/object:Gem::Dependency
103
143
  name: yajl-ruby
104
- requirement: &2151901800 !ruby/object:Gem::Requirement
144
+ requirement: !ruby/object:Gem::Requirement
105
145
  none: false
106
146
  requirements:
107
147
  - - ! '>='
@@ -109,10 +149,15 @@ dependencies:
109
149
  version: '0'
110
150
  type: :development
111
151
  prerelease: false
112
- version_requirements: *2151901800
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
113
158
  - !ruby/object:Gem::Dependency
114
159
  name: mongrel
115
- requirement: &2151898620 !ruby/object:Gem::Requirement
160
+ requirement: !ruby/object:Gem::Requirement
116
161
  none: false
117
162
  requirements:
118
163
  - - ~>
@@ -120,7 +165,12 @@ dependencies:
120
165
  version: 1.2.0.pre2
121
166
  type: :development
122
167
  prerelease: false
123
- version_requirements: *2151898620
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: 1.2.0.pre2
124
174
  description: EventMachine based, async HTTP Request client
125
175
  email:
126
176
  - ilya@igvita.com
@@ -169,6 +219,7 @@ files:
169
219
  - spec/encoding_spec.rb
170
220
  - spec/external_spec.rb
171
221
  - spec/fixtures/google.ca
222
+ - spec/fixtures/gzip-sample.gz
172
223
  - spec/helper.rb
173
224
  - spec/http_proxy_spec.rb
174
225
  - spec/middleware_spec.rb
@@ -199,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
250
  version: '0'
200
251
  requirements: []
201
252
  rubyforge_project: em-http-request
202
- rubygems_version: 1.8.10
253
+ rubygems_version: 1.8.24
203
254
  signing_key:
204
255
  specification_version: 3
205
256
  summary: EventMachine based, async HTTP Request client
@@ -210,6 +261,7 @@ test_files:
210
261
  - spec/encoding_spec.rb
211
262
  - spec/external_spec.rb
212
263
  - spec/fixtures/google.ca
264
+ - spec/fixtures/gzip-sample.gz
213
265
  - spec/helper.rb
214
266
  - spec/http_proxy_spec.rb
215
267
  - spec/middleware_spec.rb