Module: HTTPkit
- Defined in:
- lib/httpkit.rb,
lib/httpkit/body.rb,
lib/httpkit/client.rb,
lib/httpkit/server.rb,
lib/httpkit/promise.rb,
lib/httpkit/request.rb,
lib/httpkit/version.rb,
lib/httpkit/response.rb,
lib/httpkit/serializer.rb,
lib/httpkit/support/message.rb,
lib/httpkit/connection/status.rb,
lib/httpkit/client/body_handler.rb,
lib/httpkit/server/body_handler.rb,
lib/httpkit/server/block_handler.rb,
lib/httpkit/client/timeouts_handler.rb,
lib/httpkit/connection/eventmachine.rb,
lib/httpkit/server/timeouts_handler.rb,
lib/httpkit/support/handler_manager.rb,
lib/httpkit/client/mandatory_handler.rb,
lib/httpkit/server/mandatory_handler.rb,
lib/httpkit/client/keep_alive_handler.rb,
lib/httpkit/server/keep_alive_handler.rb
Defined Under Namespace
Modules: Connection, Support
Classes: Body, Client, Promise, Request, Response, Serializer, Server
Constant Summary
collapse
- Error =
Class.new(StandardError)
- VERSION =
'0.6.0'
Class Method Summary
collapse
Class Method Details
.random_port(address) ⇒ Object
61
62
63
64
65
66
|
# File 'lib/httpkit.rb', line 61
def self.random_port(address)
server = TCPServer.new(address, 0)
server.addr[1]
ensure
server.shutdown if server
end
|
.request(*args) ⇒ Object
76
77
78
79
80
|
# File 'lib/httpkit.rb', line 76
def self.request(*args)
uri = URI(args[1])
client = Client.start(address: uri.host, port: uri.port)
client.request(*args)
end
|
.run ⇒ Object
37
38
39
40
41
42
|
# File 'lib/httpkit.rb', line 37
def self.run
start do
yield
stop
end
end
|
.server(uri, &block) ⇒ Object
.sleep(duration) ⇒ Object
55
56
57
58
59
|
# File 'lib/httpkit.rb', line 55
def self.sleep(duration)
promise = Promise.new
EM.add_timer(duration) { promise.fulfill }
promise.sync
end
|
.start ⇒ Object
44
45
46
47
48
|
# File 'lib/httpkit.rb', line 44
def self.start
EM.run do
Fiber.new { yield }.resume
end
end
|
.stop ⇒ Object
50
51
52
53
|
# File 'lib/httpkit.rb', line 50
def self.stop
EM.stop
EM.next_tick {}
end
|