em-http-request 1.1.1 → 1.1.2

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a80a1bc2ca4e1dda7527f249949cb056b0beb886
4
- data.tar.gz: 4819cb821fa74543d537416994fbd65b0e0f676c
3
+ metadata.gz: 2b948340f81a9f7d6003e5c3c6d37fe37ee789f5
4
+ data.tar.gz: e0353d87fd172a5e9e31b8616e71de048cc6b23d
5
5
  SHA512:
6
- metadata.gz: b7c257493787ea81e1c1b26287aa88e4e98eba7278fa4734bdf4efe136ef1184a9f7d464dc821f35775535c649204b2331a2518bdc02e92167e062e8d5f74919
7
- data.tar.gz: 1e3f32f26b6bee0e85a11318e1cce1df5fbb9a1c5122e04e9d0610b18e2ce82ec92e04d33482d8981964b33fa36fb61090e8915be3027a86608166997b9549a3
6
+ metadata.gz: fef27697e763bf7a8147465576ec46fb7df653e867ee38265e02baae70d1a7a249fbef783dc3fe8c8cabc49906842406c2b04ea31a8a22ff3e7ccde743a8be7b
7
+ data.tar.gz: 9f85f4b4c04f81bff300adc9c0094d98b78bdf359cbb62581b1030eb4429a28a1e72a55ef2b8adb6ee559d148ea034e2c0745e9ed9ea75b12ce3b9b7cb64544d
@@ -12,13 +12,14 @@ Gem::Specification.new do |s|
12
12
  s.homepage = 'http://github.com/igrigorik/em-http-request'
13
13
  s.summary = 'EventMachine based, async HTTP Request client'
14
14
  s.description = s.summary
15
+ s.license = 'MIT'
15
16
  s.rubyforge_project = 'em-http-request'
16
17
 
17
18
  s.add_dependency 'addressable', '>= 2.3.4'
18
19
  s.add_dependency 'cookiejar'
19
20
  s.add_dependency 'em-socksify', '>= 0.3'
20
21
  s.add_dependency 'eventmachine', '>= 1.0.3'
21
- s.add_dependency 'http_parser.rb', '>= 0.6.0.beta.2'
22
+ s.add_dependency 'http_parser.rb', '>= 0.6.0'
22
23
 
23
24
  s.add_development_dependency 'mongrel', '~> 1.2.0.pre2'
24
25
  s.add_development_dependency 'multi_json'
@@ -35,17 +35,14 @@ class HttpClientOptions
35
35
 
36
36
  @uri = uri
37
37
  @path = uri.path
38
+ @host = uri.host
39
+ @port = uri.port
38
40
 
39
41
  # Make sure the ports are set as Addressable::URI doesn't
40
42
  # set the port if it isn't there
41
- if @uri.scheme == "https"
42
- @uri.port ||= 443
43
- else
44
- @uri.port ||= 80
43
+ if @port.nil?
44
+ @port = @uri.scheme == "https" ? 443 : 80
45
45
  end
46
46
 
47
- @host = @uri.host
48
- @port = @uri.port
49
-
50
47
  end
51
48
  end
@@ -39,7 +39,7 @@ module EventMachine
39
39
  end
40
40
 
41
41
  def encode_host
42
- if @req.uri.port == 80 || @req.uri.port == 443
42
+ if @req.uri.port.nil? || @req.uri.port == 80 || @req.uri.port == 443
43
43
  return @req.uri.host
44
44
  else
45
45
  @req.uri.host + ":#{@req.uri.port}"
@@ -1,5 +1,5 @@
1
1
  module EventMachine
2
2
  class HttpRequest
3
- VERSION = "1.1.1"
3
+ VERSION = "1.1.2"
4
4
  end
5
5
  end
@@ -42,7 +42,7 @@ describe EventMachine::HttpRequest do
42
42
  http.response.should match(/Hello/)
43
43
  EventMachine.stop
44
44
  }
45
- }.should_not raise_error(ArgumentError)
45
+ }.should_not raise_error
46
46
 
47
47
  }
48
48
  end
@@ -37,8 +37,8 @@ describe EventMachine::MultiRequest do
37
37
 
38
38
  describe "#requests" do
39
39
  it "should return the added requests" do
40
- request1 = stub('request1', :callback => nil, :errback => nil)
41
- request2 = stub('request2', :callback => nil, :errback => nil)
40
+ request1 = double('request1', :callback => nil, :errback => nil)
41
+ request2 = double('request2', :callback => nil, :errback => nil)
42
42
 
43
43
  multi.add :a, request1
44
44
  multi.add :b, request2
@@ -318,4 +318,48 @@ describe EventMachine::HttpRequest do
318
318
  }
319
319
  end
320
320
 
321
+ it "should not add default http port to redirect url that don't include it" do
322
+ EventMachine.run {
323
+ conn = EventMachine::HttpRequest.new('http://127.0.0.1:8090/redirect/http_no_port')
324
+ http = conn.get :redirects => 1
325
+ http.errback {
326
+ http.last_effective_url.to_s.should == 'http://host/'
327
+ EM.stop
328
+ }
329
+ }
330
+ end
331
+
332
+ it "should not add default https port to redirect url that don't include it" do
333
+ EventMachine.run {
334
+ conn = EventMachine::HttpRequest.new('http://127.0.0.1:8090/redirect/https_no_port')
335
+ http = conn.get :redirects => 1
336
+ http.errback {
337
+ http.last_effective_url.to_s.should == 'https://host/'
338
+ EM.stop
339
+ }
340
+ }
341
+ end
342
+
343
+ it "should keep default http port in redirect url that include it" do
344
+ EventMachine.run {
345
+ conn = EventMachine::HttpRequest.new('http://127.0.0.1:8090/redirect/http_with_port')
346
+ http = conn.get :redirects => 1
347
+ http.errback {
348
+ http.last_effective_url.to_s.should == 'http://host:80/'
349
+ EM.stop
350
+ }
351
+ }
352
+ end
353
+
354
+ it "should keep default https port in redirect url that include it" do
355
+ EventMachine.run {
356
+ conn = EventMachine::HttpRequest.new('http://127.0.0.1:8090/redirect/https_with_port')
357
+ http = conn.get :redirects => 1
358
+ http.errback {
359
+ http.last_effective_url.to_s.should == 'https://host:443/'
360
+ EM.stop
361
+ }
362
+ }
363
+ end
364
+
321
365
  end
@@ -185,6 +185,22 @@ Stallion.saddle :spec do |stable|
185
185
  stable.response.status = 301
186
186
  stable.response["Location"] = "http://$$$@$!%&^"
187
187
 
188
+ elsif stable.request.path_info == '/redirect/http_no_port'
189
+ stable.response.status = 301
190
+ stable.response["Location"] = "http://host/"
191
+
192
+ elsif stable.request.path_info == '/redirect/https_no_port'
193
+ stable.response.status = 301
194
+ stable.response["Location"] = "https://host/"
195
+
196
+ elsif stable.request.path_info == '/redirect/http_with_port'
197
+ stable.response.status = 301
198
+ stable.response["Location"] = "http://host:80/"
199
+
200
+ elsif stable.request.path_info == '/redirect/https_with_port'
201
+ stable.response.status = 301
202
+ stable.response["Location"] = "https://host:443/"
203
+
188
204
  elsif stable.request.path_info == '/gzip'
189
205
  io = StringIO.new
190
206
  gzip = Zlib::GzipWriter.new(io)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-http-request
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Grigorik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-24 00:00:00.000000000 Z
11
+ date: 2013-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - '>='
74
74
  - !ruby/object:Gem::Version
75
- version: 0.6.0.beta.2
75
+ version: 0.6.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
- version: 0.6.0.beta.2
82
+ version: 0.6.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: mongrel
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -217,7 +217,8 @@ files:
217
217
  - spec/stallion.rb
218
218
  - spec/stub_server.rb
219
219
  homepage: http://github.com/igrigorik/em-http-request
220
- licenses: []
220
+ licenses:
221
+ - MIT
221
222
  metadata: {}
222
223
  post_install_message:
223
224
  rdoc_options: []
@@ -260,4 +261,3 @@ test_files:
260
261
  - spec/ssl_spec.rb
261
262
  - spec/stallion.rb
262
263
  - spec/stub_server.rb
263
- has_rdoc: