rest-core 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: 53be9b581bc7a4fcb1a7e1f1a42341c7298b9434
4
- data.tar.gz: 75f8582f77c1fd69d12e1437f487f4785b49ed6d
5
- !binary "U0hBNTEy":
6
- metadata.gz: 164029833febdeb100e027761b780eadc937085193f8713340d48fe59975e30029c6a2a2651ea67073c400bcde86524b4cde8e445f802c1b43b820aea1c48c4b
7
- data.tar.gz: 4a8d30cf61afbf17950ce3418b15791c9b948b12f14d3dc7915cf8dedad7239ed80f3cec91dbc8d5192d48149c35f2471bacbb68a7a0a4fc28d71a5b67db91c7
2
+ SHA1:
3
+ metadata.gz: 13edab18f56e62ce573dc6cff597226d8d5ade6c
4
+ data.tar.gz: e41513b602d15644f9f4000cfc85a14bd93b71f2
5
+ SHA512:
6
+ metadata.gz: 70583190f10ad4f2a90075eb894a9f12da622c585353b20a77152de34ea573f5cc1d5c9512ca9d6b19722c13baba87bc829a10a9eb77162bf95c94bdc88b1cc7
7
+ data.tar.gz: c583d03d2448e7d202a506661aea8a67be6f127f1b2ec3bf97176939585437d78fc28c5bb708f4f9fdcf2501d9e2806f2eb6a75f102949f32f5d238f34665826
data/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGES
2
2
 
3
+ ## rest-core 2.0.4 -- 2013-04-30
4
+
5
+ * [`EmHttpRequest`] Use `EM.schedule` to fix thread-safety issue.
6
+
3
7
  ## rest-core 2.0.3 -- 2013-04-01
4
8
 
5
9
  * Use `URI.escape(string, UNRESERVED)` for URI escaping instead of
@@ -8,7 +8,25 @@ require 'rest-core/middleware'
8
8
  class RestCore::EmHttpRequest
9
9
  include RestCore::Middleware
10
10
  def call env, &k
11
- future = Future.create(env, k, env[ASYNC])
11
+ future = Future.create(env, k, env[ASYNC])
12
+
13
+ # eventmachine is not thread-safe, so...
14
+ # https://github.com/igrigorik/em-http-request/issues/190#issuecomment-16995528
15
+ ::EventMachine.schedule{ request(future, env) }
16
+
17
+ env.merge(RESPONSE_BODY => future.proxy_body,
18
+ RESPONSE_STATUS => future.proxy_status,
19
+ RESPONSE_HEADERS => future.proxy_headers,
20
+ FUTURE => future)
21
+ end
22
+
23
+ def close client
24
+ (client.instance_variable_get(:@callbacks)||[]).clear
25
+ (client.instance_variable_get(:@errbacks )||[]).clear
26
+ client.close
27
+ end
28
+
29
+ def request future, env
12
30
  payload = ::RestClient::Payload.generate(env[REQUEST_PAYLOAD])
13
31
  client = ::EventMachine::HttpRequest.new(request_uri(env)).send(
14
32
  env[REQUEST_METHOD],
@@ -21,18 +39,13 @@ class RestCore::EmHttpRequest
21
39
  client.response_header.status,
22
40
  client.response_header)}
23
41
 
24
- client.errback{future.on_error(client.error) }
42
+ client.errback{
43
+ close(client)
44
+ future.on_error(client.error)}
25
45
 
26
46
  env[TIMER].on_timeout{
27
- (client.instance_variable_get(:@callbacks)||[]).clear
28
- (client.instance_variable_get(:@errbacks )||[]).clear
29
- client.close
47
+ close(client)
30
48
  future.on_error(env[TIMER].error)
31
49
  } if env[TIMER]
32
-
33
- env.merge(RESPONSE_BODY => future.proxy_body,
34
- RESPONSE_STATUS => future.proxy_status,
35
- RESPONSE_HEADERS => future.proxy_headers,
36
- FUTURE => future)
37
50
  end
38
51
  end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module RestCore
3
- VERSION = '2.0.3'
3
+ VERSION = '2.0.4'
4
4
  end
data/rest-core.gemspec CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "rest-core"
5
- s.version = "2.0.3"
5
+ s.version = "2.0.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [
9
9
  "Cardinal Blue",
10
10
  "Lin Jen-Shin (godfat)"]
11
- s.date = "2013-04-01"
11
+ s.date = "2013-04-30"
12
12
  s.description = "Modular Ruby clients interface for REST APIs\n\nThere has been an explosion in the number of REST APIs available today.\nTo address the need for a way to access these APIs easily and elegantly,\nwe have developed rest-core, which consists of composable middleware\nthat allows you to build a REST client for any REST API. Or in the case of\ncommon APIs such as Facebook, Github, and Twitter, you can simply use the\ndedicated clients provided by [rest-more][].\n\n[rest-more]: https://github.com/cardinalblue/rest-more"
13
13
  s.email = ["dev (XD) cardinalblue.com"]
14
14
  s.files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cardinal Blue
@@ -9,39 +9,33 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-01 00:00:00.000000000 Z
12
+ date: 2013-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ! '>='
18
+ - - '>='
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ! '>='
25
+ - - '>='
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
- description: ! 'Modular Ruby clients interface for REST APIs
29
-
28
+ description: |-
29
+ Modular Ruby clients interface for REST APIs
30
30
 
31
31
  There has been an explosion in the number of REST APIs available today.
32
-
33
32
  To address the need for a way to access these APIs easily and elegantly,
34
-
35
33
  we have developed rest-core, which consists of composable middleware
36
-
37
34
  that allows you to build a REST client for any REST API. Or in the case of
38
-
39
35
  common APIs such as Facebook, Github, and Twitter, you can simply use the
40
-
41
36
  dedicated clients provided by [rest-more][].
42
37
 
43
-
44
- [rest-more]: https://github.com/cardinalblue/rest-more'
38
+ [rest-more]: https://github.com/cardinalblue/rest-more
45
39
  email:
46
40
  - dev (XD) cardinalblue.com
47
41
  executables: []
@@ -137,12 +131,12 @@ require_paths:
137
131
  - lib
138
132
  required_ruby_version: !ruby/object:Gem::Requirement
139
133
  requirements:
140
- - - ! '>='
134
+ - - '>='
141
135
  - !ruby/object:Gem::Version
142
136
  version: '0'
143
137
  required_rubygems_version: !ruby/object:Gem::Requirement
144
138
  requirements:
145
- - - ! '>='
139
+ - - '>='
146
140
  - !ruby/object:Gem::Version
147
141
  version: '0'
148
142
  requirements: []