em-http-request 1.0.0.beta.4 → 1.0.0

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.

data/README.md CHANGED
@@ -46,11 +46,13 @@ Several higher-order Ruby projects have incorporated em-http and other Ruby HTTP
46
46
 
47
47
  ## Other libraries & applications using EM-HTTP
48
48
 
49
- - [chirpstream](http://github.com/joshbuddy/chirpstream) - EM client for Twitters Chirpstream API
50
- - [rsolr-async](http://github.com/mwmitchell/rsolr-async) - An asynchronus connection adapter for RSolr
51
- - [PubSubHubbub](http://github.com/igrigorik/PubSubHubbub) - Asynchronous PubSubHubbub ruby client
52
- - [Firering](http://github.com/EmmanuelOga/firering) - Eventmachine powered Campfire API
53
- - [RDaneel](http://github.com/hasmanydevelopers/RDaneel) - Ruby crawler which respects robots.txt
49
+ - [chirpstream](https://github.com/joshbuddy/chirpstream) - EM client for Twitters Chirpstream API
50
+ - [rsolr-async](https://github.com/mwmitchell/rsolr-async) - An asynchronus connection adapter for RSolr
51
+ - [PubSubHubbub](https://github.com/igrigorik/PubSubHubbub) - Asynchronous PubSubHubbub ruby client
52
+ - [Firering](https://github.com/EmmanuelOga/firering) - Eventmachine powered Campfire API
53
+ - [RDaneel](https://github.com/hasmanydevelopers/RDaneel) - Ruby crawler which respects robots.txt
54
+ - [em-eventsource](https://github.com/AF83/em-eventsource) - EventSource client for EventMachine
55
+ - [sinatra-synchrony](https://github.com/kyledrake/sinatra-synchrony) - Sinatra plugin for synchronous use of EM
54
56
  - and many others.. drop me a link if you want yours included!
55
57
 
56
58
  ### License
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.add_dependency "eventmachine", ">= 1.0.0.beta.3"
18
18
  s.add_dependency "addressable", ">= 2.2.3"
19
- s.add_dependency "http_parser.rb", ">= 0.5.1"
19
+ s.add_dependency "http_parser.rb", ">= 0.5.2"
20
20
  s.add_dependency "em-socksify"
21
21
 
22
22
  s.add_development_dependency "rspec"
@@ -1,3 +1,5 @@
1
+ $: << 'lib' << '../lib'
2
+
1
3
  require 'eventmachine'
2
4
  require 'em-http'
3
5
  require 'fiber'
@@ -9,21 +11,23 @@ def async_fetch(url)
9
11
  f = Fiber.current
10
12
  http = EventMachine::HttpRequest.new(url).get :timeout => 10
11
13
 
12
- if http.error.empty?
13
- http.callback { f.resume(http) }
14
- http.errback { f.resume(http) }
14
+ http.callback { f.resume(http) }
15
+ http.errback { f.resume(http) }
16
+
17
+ Fiber.yield
15
18
 
16
- Fiber.yield
17
- else
18
- http
19
+ if http.error
20
+ p [:HTTP_ERROR, http.error]
19
21
  end
22
+
23
+ http
20
24
  end
21
25
 
22
26
  EventMachine.run do
23
27
  Fiber.new{
24
28
 
25
29
  puts "Setting up HTTP request #1"
26
- data = async_fetch('http://www.google.moo/')
30
+ data = async_fetch('http://0.0.0.0/')
27
31
  puts "Fetched page #1: #{data.response_header.status}"
28
32
 
29
33
  puts "Setting up HTTP request #2"
data/examples/multi.rb ADDED
@@ -0,0 +1,25 @@
1
+ $: << '../lib' << 'lib'
2
+
3
+ require 'eventmachine'
4
+ require 'em-http'
5
+
6
+ EventMachine.run {
7
+ multi = EventMachine::MultiRequest.new
8
+
9
+ reqs = [
10
+ 'http://google.com/',
11
+ 'http://google.ca:81/'
12
+ ]
13
+
14
+ reqs.each_with_index do |url, idx|
15
+ http = EventMachine::HttpRequest.new(url, :connect_timeout => 1)
16
+ req = http.get
17
+ multi.add idx, req
18
+ end
19
+
20
+ multi.callback do
21
+ p multi.responses[:callback].size
22
+ p multi.responses[:errback].size
23
+ EventMachine.stop
24
+ end
25
+ }
data/lib/em-http.rb CHANGED
@@ -10,6 +10,7 @@ require 'em-http/core_ext/bytesize'
10
10
  require 'em-http/http_connection'
11
11
  require 'em-http/http_header'
12
12
  require 'em-http/http_encoding'
13
+ require 'em-http/http_status_codes'
13
14
  require 'em-http/http_client_options'
14
15
  require 'em-http/http_connection_options'
15
16
  require 'em-http/client'
@@ -3,6 +3,7 @@ module EventMachine
3
3
  class HttpClient
4
4
  include Deferrable
5
5
  include HttpEncoding
6
+ include HttpStatus
6
7
 
7
8
  TRANSFER_ENCODING="TRANSFER_ENCODING"
8
9
  CONTENT_ENCODING="CONTENT_ENCODING"
@@ -36,7 +37,7 @@ module EventMachine
36
37
  @state = :response_header
37
38
 
38
39
  @response = ''
39
- @error = ''
40
+ @error = nil
40
41
  @content_decoder = nil
41
42
  @content_charset = nil
42
43
  end
@@ -78,7 +79,7 @@ module EventMachine
78
79
  @response_header.location && @req.follow_redirect?
79
80
  end
80
81
 
81
- def unbind
82
+ def unbind(reason = nil)
82
83
  if finished?
83
84
  if redirect?
84
85
 
@@ -106,11 +107,11 @@ module EventMachine
106
107
  end
107
108
 
108
109
  else
109
- fail(self)
110
+ on_error(reason)
110
111
  end
111
112
  end
112
113
 
113
- def on_error(msg = '')
114
+ def on_error(msg = nil)
114
115
  @error = msg
115
116
  fail(self)
116
117
  end
@@ -207,7 +208,7 @@ module EventMachine
207
208
 
208
209
  @response_header.http_version = version.join('.')
209
210
  @response_header.http_status = status
210
- @response_header.http_reason = 'unknown'
211
+ @response_header.http_reason = CODE[status] || 'unknown'
211
212
 
212
213
  # invoke headers callback after full parse
213
214
  # if one is specified by the user
@@ -25,8 +25,8 @@ module EventMachine
25
25
  @parent.connection_completed
26
26
  end
27
27
 
28
- def unbind
29
- @parent.unbind
28
+ def unbind(reason=nil)
29
+ @parent.unbind(reason)
30
30
  end
31
31
  end
32
32
 
@@ -103,6 +103,7 @@ module EventMachine
103
103
  @pending = []
104
104
 
105
105
  @p = Http::Parser.new
106
+ @p.header_value_type = :mixed
106
107
  @p.on_headers_complete = proc do |h|
107
108
  client.parse_response_header(h, @p.http_version, @p.status_code)
108
109
  end
@@ -156,8 +157,8 @@ module EventMachine
156
157
  @pending.push client
157
158
  end
158
159
 
159
- def unbind
160
- @clients.map { |c| c.unbind }
160
+ def unbind(reason)
161
+ @clients.map { |c| c.unbind(reason) }
161
162
 
162
163
  if r = @pending.shift
163
164
  @clients.push r
@@ -174,6 +175,7 @@ module EventMachine
174
175
  end
175
176
  end
176
177
  end
178
+ alias :close :unbind
177
179
 
178
180
  def send_data(data)
179
181
  @conn.send_data data
@@ -0,0 +1,43 @@
1
+ module EventMachine
2
+ module HttpStatus
3
+ CODE = {
4
+ 100 => 'Continue',
5
+ 101 => 'Switching Protocols',
6
+ 200 => 'OK',
7
+ 201 => 'Created',
8
+ 202 => 'Accepted',
9
+ 203 => 'Non-Authoritative Information',
10
+ 204 => 'No Content',
11
+ 205 => 'Reset Content',
12
+ 206 => 'Partial Content',
13
+ 300 => 'Multiple Choices',
14
+ 301 => 'Moved Permanently',
15
+ 302 => 'Moved Temporarily',
16
+ 303 => 'See Other',
17
+ 304 => 'Not Modified',
18
+ 305 => 'Use Proxy',
19
+ 400 => 'Bad Request',
20
+ 401 => 'Unauthorized',
21
+ 402 => 'Payment Required',
22
+ 403 => 'Forbidden',
23
+ 404 => 'Not Found',
24
+ 405 => 'Method Not Allowed',
25
+ 406 => 'Not Acceptable',
26
+ 407 => 'Proxy Authentication Required',
27
+ 408 => 'Request Time-out',
28
+ 409 => 'Conflict',
29
+ 410 => 'Gone',
30
+ 411 => 'Length Required',
31
+ 412 => 'Precondition Failed',
32
+ 413 => 'Request Entity Too Large',
33
+ 414 => 'Request-URI Too Large',
34
+ 415 => 'Unsupported Media Type',
35
+ 500 => 'Internal Server Error',
36
+ 501 => 'Not Implemented',
37
+ 502 => 'Bad Gateway',
38
+ 503 => 'Service Unavailable',
39
+ 504 => 'Gateway Time-out',
40
+ 505 => 'HTTP Version not supported'
41
+ }
42
+ end
43
+ end
@@ -1,18 +1,37 @@
1
- require 'oauth'
2
- require 'oauth/client/em_http'
1
+ require 'simple_oauth'
3
2
 
4
3
  module EventMachine
5
4
  module Middleware
6
5
 
7
6
  class OAuth
7
+ include HttpEncoding
8
+
8
9
  def initialize(opts = {})
9
- @consumer = ::OAuth::Consumer.new(opts[:consumer_key], opts[:consumer_secret])
10
- @access_token = ::OAuth::AccessToken.new(@consumer, opts[:access_token], opts[:access_token_secret])
10
+ @opts = opts.dup
11
+ # Allow both `oauth` gem and `simple_oauth` gem opts formats
12
+ @opts[:token] ||= @opts.delete(:access_token)
13
+ @opts[:token_secret] ||= @opts.delete(:access_token_secret)
11
14
  end
12
15
 
13
16
  def request(client, head, body)
14
- @consumer.sign!(client, @access_token)
15
- head.merge!(client.options[:head])
17
+ request = client.req
18
+ uri = request.uri.join(encode_query(request.uri, request.query))
19
+ params = {}
20
+
21
+ # from https://github.com/oauth/oauth-ruby/blob/master/lib/oauth/request_proxy/em_http_request.rb
22
+ if ["POST", "PUT"].include?(request.method)
23
+ head["content-type"] ||= "application/x-www-form-urlencoded" if body.is_a? Hash
24
+ form_encoded = head["content-type"].to_s.downcase.start_with?("application/x-www-form-urlencoded")
25
+
26
+ if form_encoded
27
+ CGI.parse(client.normalize_body(body)).each do |k,v|
28
+ # Since `CGI.parse` always returns values as an array
29
+ params[k] = v.size == 1 ? v.first : v
30
+ end
31
+ end
32
+ end
33
+
34
+ head["Authorization"] = SimpleOAuth::Header.new(request.method, uri, params, @opts)
16
35
 
17
36
  [head,body]
18
37
  end
@@ -1,5 +1,5 @@
1
1
  module EventMachine
2
2
  class HttpRequest
3
- VERSION = "1.0.0.beta.4"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
data/spec/client_spec.rb CHANGED
@@ -97,6 +97,32 @@ describe EventMachine::HttpRequest do
97
97
  }
98
98
  end
99
99
 
100
+ it "should return HTTP reason" do
101
+ EventMachine.run {
102
+ http = EventMachine::HttpRequest.new('http://127.0.0.1:8090/fail').get
103
+
104
+ http.errback { failed(http) }
105
+ http.callback {
106
+ http.response_header.status.should == 404
107
+ http.response_header.http_reason.should == 'Not Found'
108
+ EventMachine.stop
109
+ }
110
+ }
111
+ end
112
+
113
+ it "should return HTTP reason 'unknown' on a non-standard status code" do
114
+ EventMachine.run {
115
+ http = EventMachine::HttpRequest.new('http://127.0.0.1:8090/fail_with_nonstandard_response').get
116
+
117
+ http.errback { failed(http) }
118
+ http.callback {
119
+ http.response_header.status.should == 420
120
+ http.response_header.http_reason.should == 'unknown'
121
+ EventMachine.stop
122
+ }
123
+ }
124
+ end
125
+
100
126
  it "should build query parameters from Hash" do
101
127
  EventMachine.run {
102
128
  http = EventMachine::HttpRequest.new('http://127.0.0.1:8090/').get :query => {:q => 'test'}
@@ -539,6 +565,22 @@ describe EventMachine::HttpRequest do
539
565
  }
540
566
  end
541
567
 
568
+ it "should return array of cookies on multiple Set-Cookie headers" do
569
+ EventMachine.run {
570
+ http = EventMachine::HttpRequest.new('http://127.0.0.1:8090/set_multiple_cookies').get
571
+
572
+ http.errback { failed(http) }
573
+ http.callback {
574
+ http.response_header.status.should == 200
575
+ http.response_header.cookie.size.should == 2
576
+ http.response_header.cookie.first.should == "id=1; expires=Tue, 09-Aug-2011 17:53:39 GMT; path=/;"
577
+ http.response_header.cookie.last.should == "id=2;"
578
+
579
+ EventMachine.stop
580
+ }
581
+ }
582
+ end
583
+
542
584
  it "should pass cookie header to server from string" do
543
585
  EventMachine.run {
544
586
  http = EventMachine::HttpRequest.new('http://127.0.0.1:8090/echo_cookie').get :head => {'cookie' => 'id=2;'}
@@ -1,5 +1,4 @@
1
1
  require 'helper'
2
- require 'em-http/middleware/cookie_jar'
3
2
 
4
3
  describe EventMachine::HttpRequest do
5
4
 
@@ -141,52 +140,4 @@ describe EventMachine::HttpRequest do
141
140
  end
142
141
  end
143
142
 
144
- context "CookieJar" do
145
- it "should use the cookie jar as opposed to any other method when in use" do
146
- lambda {
147
- EventMachine.run {
148
- conn = EventMachine::HttpRequest.new('http://127.0.0.1:8090/')
149
- middleware = EventMachine::Middleware::CookieJar
150
- conn.use middleware
151
- middleware.set_cookie('http://127.0.0.1:8090/', 'id=1')
152
- req = conn.get :head => {'cookie' => 'id=2;'}
153
- req.callback { failed(req) }
154
- req.errback { failed(req) }
155
- }
156
- }.should raise_error(ArgumentError)
157
- end
158
-
159
- it "should send cookies" do
160
- EventMachine.run {
161
- uri = 'http://127.0.0.1:8090/cookie_parrot'
162
- conn = EventMachine::HttpRequest.new(uri)
163
- middleware = EventMachine::Middleware::CookieJar
164
- conn.use middleware
165
- middleware.set_cookie(uri, 'id=1')
166
- req = conn.get
167
- req.callback {
168
- req.response_header.cookie.should == 'id=1'
169
- EventMachine.stop
170
- }
171
- }
172
- end
173
-
174
- it "should store cookies and send them" do
175
- EventMachine.run {
176
- uri = 'http://127.0.0.1:8090/set_cookie'
177
- conn = EventMachine::HttpRequest.new(uri)
178
- middleware = EventMachine::Middleware::CookieJar
179
- conn.use middleware
180
- req = conn.get
181
- req.callback {
182
- req.response_header.cookie[0..3].should == 'id=1'
183
- cookies = middleware.cookiejar.get_cookies(uri)
184
- cookies.length.should == 1
185
- cookies[0].to_s.should == "id=1"
186
- EventMachine.stop
187
- }
188
- }
189
- end
190
- end
191
-
192
143
  end
data/spec/stallion.rb CHANGED
@@ -74,6 +74,9 @@ Stallion.saddle :spec do |stable|
74
74
  if stable.request.path_info == '/fail'
75
75
  stable.response.status = 404
76
76
 
77
+ elsif stable.request.path_info == '/fail_with_nonstandard_response'
78
+ stable.response.status = 420
79
+
77
80
  elsif stable.request.query_string == 'q=test'
78
81
  stable.response.write 'test'
79
82
 
@@ -106,6 +109,13 @@ Stallion.saddle :spec do |stable|
106
109
  stable.response["Set-Cookie"] = "id=1; expires=Tue, 09-Aug-2011 17:53:39 GMT; path=/;"
107
110
  stable.response.write "cookie set"
108
111
 
112
+ elsif stable.request.path_info == '/set_multiple_cookies'
113
+ stable.response["Set-Cookie"] = [
114
+ "id=1; expires=Tue, 09-Aug-2011 17:53:39 GMT; path=/;",
115
+ "id=2;"
116
+ ]
117
+ stable.response.write "cookies set"
118
+
109
119
  elsif stable.request.path_info == '/echo_cookie'
110
120
  stable.response.write stable.request.env["HTTP_COOKIE"]
111
121
 
@@ -177,7 +187,7 @@ Stallion.saddle :spec do |stable|
177
187
  deflater.deflate("compressed")
178
188
  stable.response.write deflater.finish
179
189
  stable.response["Content-Encoding"] = "deflate"
180
-
190
+
181
191
  elsif stable.request.env["HTTP_IF_NONE_MATCH"]
182
192
  stable.response.status = 304
183
193
 
metadata CHANGED
@@ -1,138 +1,133 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: em-http-request
3
- version: !ruby/object:Gem::Version
4
- prerelease: 6
5
- version: 1.0.0.beta.4
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Ilya Grigorik
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-05-27 00:00:00 -07:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2011-08-27 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: eventmachine
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2152766660 !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
24
21
  version: 1.0.0.beta.3
25
22
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: addressable
29
23
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2152766660
25
+ - !ruby/object:Gem::Dependency
26
+ name: addressable
27
+ requirement: &2152766160 !ruby/object:Gem::Requirement
31
28
  none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
35
32
  version: 2.2.3
36
33
  type: :runtime
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: http_parser.rb
40
34
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *2152766160
36
+ - !ruby/object:Gem::Dependency
37
+ name: http_parser.rb
38
+ requirement: &2152765700 !ruby/object:Gem::Requirement
42
39
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 0.5.1
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 0.5.2
47
44
  type: :runtime
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: em-socksify
51
45
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *2152765700
47
+ - !ruby/object:Gem::Dependency
48
+ name: em-socksify
49
+ requirement: &2152765320 !ruby/object:Gem::Requirement
53
50
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
58
55
  type: :runtime
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: rspec
62
56
  prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *2152765320
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec
60
+ requirement: &2152764860 !ruby/object:Gem::Requirement
64
61
  none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: "0"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
69
66
  type: :development
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
72
- name: rake
73
67
  prerelease: false
74
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *2152764860
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: &2152764440 !ruby/object:Gem::Requirement
75
72
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
80
77
  type: :development
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
83
- name: rack
84
78
  prerelease: false
85
- requirement: &id007 !ruby/object:Gem::Requirement
79
+ version_requirements: *2152764440
80
+ - !ruby/object:Gem::Dependency
81
+ name: rack
82
+ requirement: &2152764020 !ruby/object:Gem::Requirement
86
83
  none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
91
88
  type: :development
92
- version_requirements: *id007
93
- - !ruby/object:Gem::Dependency
94
- name: yajl-ruby
95
89
  prerelease: false
96
- requirement: &id008 !ruby/object:Gem::Requirement
90
+ version_requirements: *2152764020
91
+ - !ruby/object:Gem::Dependency
92
+ name: yajl-ruby
93
+ requirement: &2152763600 !ruby/object:Gem::Requirement
97
94
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- version: "0"
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
102
99
  type: :development
103
- version_requirements: *id008
104
- - !ruby/object:Gem::Dependency
105
- name: cookiejar
106
100
  prerelease: false
107
- requirement: &id009 !ruby/object:Gem::Requirement
101
+ version_requirements: *2152763600
102
+ - !ruby/object:Gem::Dependency
103
+ name: cookiejar
104
+ requirement: &2152763180 !ruby/object:Gem::Requirement
108
105
  none: false
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- version: "0"
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
113
110
  type: :development
114
- version_requirements: *id009
115
- - !ruby/object:Gem::Dependency
116
- name: mongrel
117
111
  prerelease: false
118
- requirement: &id010 !ruby/object:Gem::Requirement
112
+ version_requirements: *2152763180
113
+ - !ruby/object:Gem::Dependency
114
+ name: mongrel
115
+ requirement: &2152762680 !ruby/object:Gem::Requirement
119
116
  none: false
120
- requirements:
117
+ requirements:
121
118
  - - ~>
122
- - !ruby/object:Gem::Version
119
+ - !ruby/object:Gem::Version
123
120
  version: 1.2.0.pre2
124
121
  type: :development
125
- version_requirements: *id010
122
+ prerelease: false
123
+ version_requirements: *2152762680
126
124
  description: EventMachine based, async HTTP Request client
127
- email:
125
+ email:
128
126
  - ilya@igvita.com
129
127
  executables: []
130
-
131
128
  extensions: []
132
-
133
129
  extra_rdoc_files: []
134
-
135
- files:
130
+ files:
136
131
  - .gemtest
137
132
  - .gitignore
138
133
  - .rspec
@@ -149,6 +144,7 @@ files:
149
144
  - examples/.gitignore
150
145
  - examples/fetch.rb
151
146
  - examples/fibered-http.rb
147
+ - examples/multi.rb
152
148
  - examples/oauth-tweet.rb
153
149
  - examples/socks5.rb
154
150
  - lib/em-http-request.rb
@@ -161,7 +157,7 @@ files:
161
157
  - lib/em-http/http_connection_options.rb
162
158
  - lib/em-http/http_encoding.rb
163
159
  - lib/em-http/http_header.rb
164
- - lib/em-http/middleware/cookie_jar.rb
160
+ - lib/em-http/http_status_codes.rb
165
161
  - lib/em-http/middleware/json_response.rb
166
162
  - lib/em-http/middleware/oauth.rb
167
163
  - lib/em-http/multi.rb
@@ -182,35 +178,31 @@ files:
182
178
  - spec/ssl_spec.rb
183
179
  - spec/stallion.rb
184
180
  - spec/stub_server.rb
185
- has_rdoc: true
186
181
  homepage: http://github.com/igrigorik/em-http-request
187
182
  licenses: []
188
-
189
183
  post_install_message:
190
184
  rdoc_options: []
191
-
192
- require_paths:
185
+ require_paths:
193
186
  - lib
194
- required_ruby_version: !ruby/object:Gem::Requirement
187
+ required_ruby_version: !ruby/object:Gem::Requirement
195
188
  none: false
196
- requirements:
197
- - - ">="
198
- - !ruby/object:Gem::Version
199
- version: "0"
200
- required_rubygems_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ! '>='
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ required_rubygems_version: !ruby/object:Gem::Requirement
201
194
  none: false
202
- requirements:
203
- - - ">"
204
- - !ruby/object:Gem::Version
205
- version: 1.3.1
195
+ requirements:
196
+ - - ! '>='
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
206
199
  requirements: []
207
-
208
200
  rubyforge_project: em-http-request
209
- rubygems_version: 1.6.2
201
+ rubygems_version: 1.8.5
210
202
  signing_key:
211
203
  specification_version: 3
212
204
  summary: EventMachine based, async HTTP Request client
213
- test_files:
205
+ test_files:
214
206
  - spec/client_spec.rb
215
207
  - spec/dns_spec.rb
216
208
  - spec/encoding_spec.rb
@@ -1,38 +0,0 @@
1
- require 'cookiejar'
2
-
3
- module EventMachine
4
- module Middleware
5
- class CookieJar
6
- class << self
7
- attr_reader :cookiejar
8
-
9
- def cookiejar=(val)
10
- @cookiejar = val
11
- end
12
-
13
- def set_cookie(url, cookie)
14
- @cookiejar.set_cookie url, cookie
15
- end
16
- end
17
-
18
- def request(c, h, r)
19
- raise ArgumentError, "You may not set cookies outside of the cookie jar" if h.delete('cookie')
20
- cookies = CookieJar::cookiejar.get_cookie_header(c.last_effective_url)
21
- h['cookie'] = cookies unless cookies.empty?
22
- [h, r]
23
- end
24
-
25
- def response(r)
26
- cookies = r.response_header.cookie
27
- if cookies
28
- [cookies].flatten.each { |c|
29
- EventMachine::Middleware::CookieJar.cookiejar.set_cookie r.last_effective_url, c
30
- }
31
- end
32
- r.response
33
- end
34
- end
35
- end
36
- end
37
-
38
- EventMachine::Middleware::CookieJar.cookiejar = CookieJar::Jar.new