Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add options and patch verbs to em-synchrony/em-http

  • Loading branch information...
commit fe1a05aac515a9f1c820fff4b4f99c4c969ac15a 1 parent a8b6b8b
@therabidbanana therabidbanana authored
Showing with 8 additions and 4 deletions.
  1. +2 −2 lib/em-synchrony/em-http.rb
  2. +6 −2 spec/http_spec.rb
View
4 lib/em-synchrony/em-http.rb
@@ -6,7 +6,7 @@
module EventMachine
module HTTPMethods
- %w[get head post delete put].each do |type|
+ %w[get head post delete put patch options].each do |type|
class_eval %[
alias :a#{type} :#{type}
def #{type}(options = {}, &blk)
@@ -16,7 +16,7 @@ def #{type}(options = {}, &blk)
if conn.error.nil?
conn.callback { f.resume(conn) }
conn.errback { f.resume(conn) }
-
+
Fiber.yield
else
conn
View
8 spec/http_spec.rb
@@ -28,9 +28,11 @@
order.push :head if EventMachine::HttpRequest.new(URL).head
order.push :post if EventMachine::HttpRequest.new(URL).delete
order.push :put if EventMachine::HttpRequest.new(URL).put
+ order.push :options if EventMachine::HttpRequest.new(URL).options
+ order.push :patch if EventMachine::HttpRequest.new(URL).patch
(now - start.to_f).should be_within(DELAY * order.size * 0.15).of(DELAY * order.size)
- order.should == [:get, :post, :head, :post, :put]
+ order.should == [:get, :post, :head, :post, :put, :options, :patch]
s.stop
EventMachine.stop
@@ -49,10 +51,12 @@
multi.add :c, EventMachine::HttpRequest.new(URL).ahead
multi.add :d, EventMachine::HttpRequest.new(URL).adelete
multi.add :e, EventMachine::HttpRequest.new(URL).aput
+ multi.add :f, EventMachine::HttpRequest.new(URL).aoptions
+ multi.add :g, EventMachine::HttpRequest.new(URL).apatch
res = multi.perform
(now - start.to_f).should be_within(DELAY * 0.15).of(DELAY)
- res.responses[:callback].size.should == 5
+ res.responses[:callback].size.should == 7
res.responses[:errback].size.should == 0
s.stop
Please sign in to comment.
Something went wrong with that request. Please try again.