emmy-http 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -2
- data/emmy-http.gemspec +3 -2
- data/lib/emmy_http/model.rb +115 -5
- data/lib/emmy_http/operation.rb +9 -1
- data/lib/emmy_http/refines.rb +11 -0
- data/lib/emmy_http/request.rb +20 -11
- data/lib/emmy_http/response.rb +33 -8
- data/lib/emmy_http/utils.rb +1 -1
- data/lib/emmy_http/version.rb +1 -1
- data/lib/emmy_http.rb +18 -2
- data/spec/emmy_http/model_spec.rb +34 -0
- data/spec/emmy_http_spec.rb +41 -69
- data/spec/fakes.rb +40 -0
- metadata +36 -6
- data/lib/emmy_http/server/options.rb +0 -19
- data/pkg/emmy-http-0.1.0.gem +0 -0
- data/pkg/emmy-http-0.1.1.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0971c78d06be99618226ee14b9eb60c57c5cf535
|
4
|
+
data.tar.gz: b6a4c6026afbaab8215cea42689bae329b119555
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33f5fc5aafa7d59ba0865dbdd3f2ca2c3c45325bdcfd30244b1c4e8e4170252ae67895f99e2ee061a97a8388a3ffd8a3b7e5583bb59e208f166403cb41586fc0
|
7
|
+
data.tar.gz: 6b499296b451a6bac10b39c872c5bd0bae17cd1cf4faf42c8cdbd96677b20fecbc6cccc66ba6fadb1879389ab0d7e1adbf7a16c883239deab79ead719ec9700d
|
data/Gemfile
CHANGED
data/emmy-http.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = EmmyHttp::VERSION
|
9
9
|
spec.authors = ["inre"]
|
10
10
|
spec.email = ["inre.storm@gmail.com"]
|
11
|
-
spec.summary = %q{EmmyHttp
|
11
|
+
spec.summary = %q{EmmyHttp - EventMachine's HTTP Client}
|
12
12
|
#spec.description = %q{TODO: Write a longer description. Optional.}
|
13
13
|
spec.homepage = ""
|
14
14
|
spec.license = "MIT"
|
@@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
|
21
|
+
spec.add_dependency "event_object", "~> 0.9.1"
|
22
|
+
spec.add_dependency "emmy-machine", "~> 0.1.7"
|
22
23
|
spec.add_dependency "fibre", "~> 0.9.3"
|
23
24
|
spec.add_dependency "util_pack", "~> 0.1"
|
24
25
|
spec.add_dependency "model_pack", "~> 0.9.6"
|
data/lib/emmy_http/model.rb
CHANGED
@@ -1,20 +1,130 @@
|
|
1
1
|
#
|
2
2
|
# class Google
|
3
|
-
# include
|
4
|
-
# adapter
|
5
|
-
#
|
6
|
-
# type: "post",
|
3
|
+
# include EmmyHttp::Model
|
4
|
+
# adapter EmmyExtends::EmHttpRequest
|
5
|
+
# defaults {
|
7
6
|
# headers: {
|
8
7
|
# 'Content-Type' => 'application/json'
|
9
8
|
# }
|
10
|
-
#
|
9
|
+
# }
|
10
|
+
#
|
11
|
+
# post ''
|
11
12
|
# end
|
12
13
|
#
|
13
14
|
# google = Google.new(url: 'http://google.com')
|
14
15
|
# response = google.sync
|
15
16
|
|
17
|
+
#
|
18
|
+
# module DigitalOcean
|
19
|
+
# using EventObject
|
20
|
+
# API_TOKEN = "b7d03a6947b217efb6f3ec3bd3504582"
|
21
|
+
#
|
22
|
+
# class DigitalOcean::Error < StandardError; end
|
23
|
+
#
|
24
|
+
# class Request
|
25
|
+
# include EmmyHttp::Model
|
26
|
+
# adapter EmmyHttp::Client::Adapter
|
27
|
+
# header 'Content-Type' => 'application/json'
|
28
|
+
# header "Authorization: Bearer #{API_TOKEN}"
|
29
|
+
#
|
30
|
+
# events :success, :error
|
31
|
+
#
|
32
|
+
# def sync
|
33
|
+
# connect
|
34
|
+
#
|
35
|
+
# Fiber.sync do |f|
|
36
|
+
# on :success do |content|
|
37
|
+
# f.resume content
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# on :error do |message|
|
41
|
+
# raise DigitalOcean::Error, message
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# def request
|
47
|
+
# op = super(
|
48
|
+
#
|
49
|
+
# ).op
|
50
|
+
#
|
51
|
+
# op.on :success do |response, operation, conn|
|
52
|
+
# success!(response.content)
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# op.on :error do |message, operation, conn|
|
56
|
+
# error!(message)
|
57
|
+
# end
|
58
|
+
# end
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
#
|
62
|
+
# class Droplets < Request
|
63
|
+
# get list: '/v2/droplets'
|
64
|
+
# post new: '/v2/droplets'
|
65
|
+
# get get: '/v2/:id'
|
66
|
+
#
|
67
|
+
#
|
68
|
+
# end
|
69
|
+
# end
|
70
|
+
require 'singleton'
|
71
|
+
|
16
72
|
module EmmyHttp
|
17
73
|
module Model
|
74
|
+
using EventObject
|
75
|
+
|
76
|
+
def self.included(base)
|
77
|
+
base.extend ClassMethods
|
78
|
+
base.include Singleton
|
79
|
+
base.include InstanceMethods
|
80
|
+
end
|
81
|
+
|
82
|
+
module InstanceMethods
|
83
|
+
def request
|
84
|
+
@request ||= EmmyHttp::Request.new
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
module ClassMethods
|
89
|
+
def request(a=nil)
|
90
|
+
instance.request.tap { |req| req.update_attributes(a) if a }
|
91
|
+
end
|
92
|
+
|
93
|
+
def adapter(name)
|
94
|
+
request.adapter = name
|
95
|
+
end
|
96
|
+
|
97
|
+
def url(uri)
|
98
|
+
request.url = uri
|
99
|
+
end
|
100
|
+
|
101
|
+
def defaults(attributes)
|
102
|
+
request.update_attributes(attributes)
|
103
|
+
end
|
104
|
+
|
105
|
+
def headers(head)
|
106
|
+
request.headers.merge!(head)
|
107
|
+
end
|
108
|
+
|
109
|
+
def raise_error(flag)
|
110
|
+
request.raise_error = flag
|
111
|
+
end
|
112
|
+
|
113
|
+
alias header headers
|
114
|
+
|
115
|
+
EmmyHttp::HTTP_METHODS.each do |name|
|
116
|
+
define_method name do |path, as: nil|
|
117
|
+
cdef as.to_s do |*a|
|
118
|
+
instance.var(as.to_s, request.copy.tap { |r| r.update_attributes(path: path) })
|
119
|
+
end
|
120
|
+
|
121
|
+
cdef "#{as}!" do |*a, &b|
|
122
|
+
send(as, *a, &b)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
18
127
|
|
128
|
+
#<<<
|
19
129
|
end
|
20
130
|
end
|
data/lib/emmy_http/operation.rb
CHANGED
@@ -20,6 +20,10 @@ module EmmyHttp
|
|
20
20
|
@connection ||= EmmyMachine.connect(*self)
|
21
21
|
end
|
22
22
|
|
23
|
+
def reconnect
|
24
|
+
EmmyMachine.reconnect(*self)
|
25
|
+
end
|
26
|
+
|
23
27
|
def sync
|
24
28
|
Fiber.sync do |fiber|
|
25
29
|
# create connection
|
@@ -42,7 +46,11 @@ module EmmyHttp
|
|
42
46
|
|
43
47
|
on :error do |error, operation, conn|
|
44
48
|
# return error as exception
|
45
|
-
|
49
|
+
if request.raise_error?
|
50
|
+
fiber.leave ConnectionError, error.to_s
|
51
|
+
else
|
52
|
+
fiber.resume nil
|
53
|
+
end
|
46
54
|
end
|
47
55
|
end
|
48
56
|
end
|
data/lib/emmy_http/request.rb
CHANGED
@@ -1,24 +1,28 @@
|
|
1
1
|
module EmmyHttp
|
2
2
|
class Request
|
3
3
|
include ModelPack::Document
|
4
|
-
|
4
|
+
using EventObject
|
5
5
|
|
6
6
|
#def_delegator :operation, :sync, :init, :head, :success, :error, :init!, :head!, :success!, :error!, :to_a
|
7
7
|
|
8
|
-
attribute :type, default: "
|
8
|
+
attribute :type, default: "GET" # word *method* reserved in ruby
|
9
9
|
attribute :url,
|
10
10
|
writer: ->(url) { url.is_a?(URI) ? url : URI.parse(url) },
|
11
11
|
serialize: ->(value) { value.to_s }
|
12
12
|
dictionary :headers
|
13
13
|
|
14
|
+
attribute :path # replace url.path
|
14
15
|
attribute :query # replace url.query
|
16
|
+
|
15
17
|
# POST, PUT
|
16
18
|
attribute :body # string, json hash
|
17
19
|
attribute :form # hash form
|
20
|
+
attribute :json # serializable hash/object to json
|
18
21
|
attribute :file # path
|
19
22
|
|
20
23
|
attribute :keep_alive, predicate: true
|
21
24
|
attribute :redirects, default: 6
|
25
|
+
attribute :raise_error, predicate: true, default: true
|
22
26
|
|
23
27
|
object :timeouts, class_name: Timeouts, default: Timeouts
|
24
28
|
object :ssl, class_name: SSL
|
@@ -27,23 +31,24 @@ module EmmyHttp
|
|
27
31
|
attribute :adapter,
|
28
32
|
writer: ->(class_name) { class_name.is_a?(String) ? constantize(class_name) : class_name },
|
29
33
|
serialize: ->(value) { value.to_s }
|
30
|
-
=begin
|
31
|
-
attribute :response_class,
|
32
|
-
writer: ->(class_name) { class_name.is_a?(String) ? constantize(class_name) : class_name },
|
33
|
-
serialize: ->(value) { value.to_s }
|
34
34
|
|
35
|
-
def initialize
|
36
|
-
@response_class = Response
|
37
|
-
end
|
38
|
-
=end
|
39
35
|
def operation
|
40
|
-
@operation ||= EmmyHttp::Operation.new(self, adapter)
|
36
|
+
@operation ||= EmmyHttp::Operation.new(self, adapter.new)
|
41
37
|
end
|
42
38
|
|
39
|
+
alias op operation
|
40
|
+
|
43
41
|
def sync
|
44
42
|
operation.sync
|
45
43
|
end
|
46
44
|
|
45
|
+
EmmyHttp::HTTP_METHODS.each do |name|
|
46
|
+
self.def name do |a={}|
|
47
|
+
update_attributes(a.is_a?(String) ? {url: a} : a)
|
48
|
+
self
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
47
52
|
# FIXME: move to model_pack
|
48
53
|
def ssl?
|
49
54
|
!!ssl
|
@@ -51,6 +56,10 @@ module EmmyHttp
|
|
51
56
|
|
52
57
|
private
|
53
58
|
|
59
|
+
def error(message)
|
60
|
+
raise RequestError, message
|
61
|
+
end
|
62
|
+
|
54
63
|
def constantize(class_name)
|
55
64
|
return nil unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ class_name
|
56
65
|
Object.module_eval("::#{$1}", __FILE__, __LINE__)
|
data/lib/emmy_http/response.rb
CHANGED
@@ -3,26 +3,30 @@ module EmmyHttp
|
|
3
3
|
using EventObject
|
4
4
|
include ModelPack::Document
|
5
5
|
|
6
|
-
attribute :status
|
6
|
+
attribute :status, default: 0
|
7
7
|
dictionary :headers, writer: -> (head) { EmmyHttp::Utils.convert_headers(head) }
|
8
|
-
attribute :body
|
8
|
+
attribute :body, default: ''
|
9
|
+
attribute :finished, predicate: true#, hidden: true
|
9
10
|
|
10
|
-
events :data
|
11
|
+
events :data, :done
|
11
12
|
|
12
13
|
def initialize
|
13
14
|
on :data do |chunk|
|
14
15
|
body << chunk
|
15
16
|
end
|
16
|
-
|
17
|
-
reset
|
18
17
|
end
|
19
18
|
|
20
|
-
def
|
19
|
+
def clear
|
21
20
|
@status = 0
|
22
21
|
@headers = {}
|
23
22
|
@body = ''
|
24
23
|
end
|
25
24
|
|
25
|
+
def finish
|
26
|
+
@finished = true
|
27
|
+
done!
|
28
|
+
end
|
29
|
+
|
26
30
|
def chunked_encoding?
|
27
31
|
headers['Transfer-Encoding'] =~ /chunked/i
|
28
32
|
end
|
@@ -35,12 +39,33 @@ module EmmyHttp
|
|
35
39
|
headers['Content-Encoding'] =~ /gzip|compressed|deflate/i
|
36
40
|
end
|
37
41
|
|
42
|
+
def content_length?
|
43
|
+
headers['Content-Length'] =~ /\A\d+\z/
|
44
|
+
end
|
45
|
+
|
46
|
+
def content_length
|
47
|
+
content_length? ? headers['Content-Length'].to_i : nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def content_type
|
51
|
+
headers['Content-Type'] =~ /\A([^;]*)/; $1
|
52
|
+
end
|
53
|
+
|
38
54
|
def location
|
39
55
|
headers['Location']
|
40
56
|
end
|
41
57
|
|
42
|
-
def
|
43
|
-
|
58
|
+
def content
|
59
|
+
@content ||= case content_type
|
60
|
+
when 'application/json'
|
61
|
+
begin
|
62
|
+
JSON.parse(body)
|
63
|
+
rescue JSON::ParserError => e
|
64
|
+
raise ParserError, e.to_s
|
65
|
+
end
|
66
|
+
else
|
67
|
+
nil
|
68
|
+
end
|
44
69
|
end
|
45
70
|
|
46
71
|
def redirection?
|
data/lib/emmy_http/utils.rb
CHANGED
data/lib/emmy_http/version.rb
CHANGED
data/lib/emmy_http.rb
CHANGED
@@ -3,8 +3,13 @@ require "emmy_http/version"
|
|
3
3
|
require "forwardable"
|
4
4
|
|
5
5
|
module EmmyHttp
|
6
|
-
class
|
7
|
-
class
|
6
|
+
class HttpError < StandardError; end
|
7
|
+
class ParserError < HttpError; end
|
8
|
+
class RequestError < HttpError; end
|
9
|
+
class ConnectionError < HttpError; end
|
10
|
+
class TimeoutError < HttpError; end
|
11
|
+
|
12
|
+
HTTP_METHODS = %w(get head delete put post patch options)
|
8
13
|
|
9
14
|
autoload :Adapter, "emmy_http/adapter"
|
10
15
|
autoload :Timeouts, "emmy_http/client/timeouts"
|
@@ -15,4 +20,15 @@ module EmmyHttp
|
|
15
20
|
autoload :Response, "emmy_http/response"
|
16
21
|
autoload :Timeout, "emmy_http/timeout"
|
17
22
|
autoload :Utils, "emmy_http/utils"
|
23
|
+
autoload :Model, "emmy_http/model"
|
24
|
+
|
25
|
+
extend self
|
26
|
+
|
27
|
+
def request(*a)
|
28
|
+
EmmyHttp::Request.new(*a).tap { |req| yield(req) if block_given? }
|
29
|
+
end
|
30
|
+
|
31
|
+
def request!(*a)
|
32
|
+
request(*a, &b).operation
|
33
|
+
end
|
18
34
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fakes"
|
3
|
+
using Fibre::Synchrony
|
4
|
+
|
5
|
+
describe EmmyHttp::Model do
|
6
|
+
|
7
|
+
before do
|
8
|
+
stub_const("EmmyMachine", FakeEventMachine)
|
9
|
+
end
|
10
|
+
|
11
|
+
class HTTPBin
|
12
|
+
include EmmyHttp::Model
|
13
|
+
adapter FakeAdapter
|
14
|
+
url "http://httpbin.org"
|
15
|
+
header "Content-Type" => "application/json"
|
16
|
+
|
17
|
+
get '/get', as: :get_request
|
18
|
+
post '/post', as: :post_request
|
19
|
+
end
|
20
|
+
|
21
|
+
around do |example|
|
22
|
+
EmmyMachine.run_block &example
|
23
|
+
end
|
24
|
+
|
25
|
+
it "have requests from model" do
|
26
|
+
res = {
|
27
|
+
get_response: HTTPBin.get_request!,
|
28
|
+
post_response: HTTPBin.post_request!(form: {a: 5, b: 6})
|
29
|
+
}.sync
|
30
|
+
|
31
|
+
expect(res[:get_response].status).to be(200)
|
32
|
+
expect(res[:post_response].status).to be(200)
|
33
|
+
end
|
34
|
+
end
|
data/spec/emmy_http_spec.rb
CHANGED
@@ -1,95 +1,67 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require "fakes"
|
2
3
|
using EventObject
|
4
|
+
using Fibre::Synchrony
|
3
5
|
|
4
6
|
describe EmmyHttp do
|
5
|
-
|
6
|
-
|
7
|
-
module FakeEventMachine
|
8
|
-
extend EmmyMachine::ClassMethods
|
9
|
-
|
10
|
-
def connect(adapter, init)
|
11
|
-
conn = Class.new
|
12
|
-
conn.extend Connection
|
13
|
-
init.call
|
14
|
-
adapter.connected(conn)
|
15
|
-
conn
|
16
|
-
end
|
17
|
-
|
18
|
-
extend self
|
19
|
-
end
|
20
|
-
|
21
|
-
class FakeAdapter
|
22
|
-
attr_accessor :delegate
|
23
|
-
include EmmyHttp::Adapter
|
24
|
-
|
25
|
-
def initialize_connection
|
26
|
-
self.delegate.init! delegate
|
27
|
-
end
|
28
|
-
|
29
|
-
def connected(conn)
|
30
|
-
# replace request with timer
|
31
|
-
EventMachine.add_timer(0) do
|
32
|
-
response = EmmyHttp::Response.new
|
33
|
-
response.headers = {'CONTENT_TYPE' => 'text/html'}
|
34
|
-
response.status = 200
|
35
|
-
self.delegate.head!(response, delegate, conn)
|
36
|
-
response.body = "OK"
|
37
|
-
self.delegate.success!(delegate.response, delegate, conn)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def to_a
|
42
|
-
[self, method(:initialize_connection)]
|
43
|
-
end
|
44
|
-
end
|
7
|
+
include EmmyHttp
|
45
8
|
|
46
9
|
before do
|
47
10
|
stub_const("EmmyMachine", FakeEventMachine)
|
48
11
|
end
|
49
12
|
|
50
13
|
around do |example|
|
51
|
-
|
52
|
-
|
53
|
-
|
14
|
+
EmmyMachine.run_block &example
|
15
|
+
end
|
16
|
+
|
17
|
+
it "do http request with fake adapter" do
|
18
|
+
request = EmmyHttp::Request.new(
|
19
|
+
type: 'get',
|
20
|
+
url: 'http://google.com'
|
21
|
+
)
|
22
|
+
operation = EmmyHttp::Operation.new(request, FakeAdapter.new)
|
23
|
+
response = operation.sync
|
24
|
+
|
25
|
+
expect(response.status).to be 200
|
26
|
+
expect(response.headers).to include("Content-Type")
|
27
|
+
expect(response.body).to eq "OK"
|
54
28
|
end
|
55
29
|
|
56
|
-
it "
|
57
|
-
|
58
|
-
request = EmmyHttp::Request.new(
|
59
|
-
type: 'get',
|
60
|
-
url: 'http://google.com'
|
61
|
-
)
|
62
|
-
operation = EmmyHttp::Operation.new(request, FakeAdapter.new)
|
63
|
-
response = operation.sync
|
64
|
-
ensure
|
65
|
-
EventMachine.stop
|
66
|
-
end
|
30
|
+
it "do http request with short syntax" do
|
31
|
+
response = request(adapter: FakeAdapter, raise_error: false).get('http://google.com').sync
|
67
32
|
|
33
|
+
expect(response).to_not be nil
|
68
34
|
expect(response.status).to be 200
|
69
35
|
expect(response.headers).to include("Content-Type")
|
70
36
|
expect(response.body).to eq "OK"
|
71
37
|
end
|
72
38
|
|
39
|
+
it "do async requests" do
|
40
|
+
req = request(adapter: FakeAdapter, raise_error: false)
|
41
|
+
responses = {
|
42
|
+
a: [req.copy.get('http://google.com').op, req.copy.get('http://google.com').op],
|
43
|
+
b: req.copy.get('http://google.com')
|
44
|
+
}.sync!
|
45
|
+
|
46
|
+
expect(responses[:a][0].status).to be 200
|
47
|
+
expect(responses[:a][1].status).to be 200
|
48
|
+
expect(responses[:b].status).to be 200
|
49
|
+
end
|
50
|
+
|
73
51
|
it "should wait a couple seconds" do
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
ensure
|
78
|
-
EventMachine.stop
|
79
|
-
end
|
52
|
+
timeout = EmmyHttp::Timeout.new(2)
|
53
|
+
res = timeout.sync
|
54
|
+
|
80
55
|
expect(res).to be true
|
81
56
|
end
|
82
57
|
|
83
58
|
it "should serialize request" do
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
ensure
|
91
|
-
EventMachine.stop
|
92
|
-
end
|
59
|
+
request = EmmyHttp::Request.new(
|
60
|
+
type: 'get',
|
61
|
+
url: 'http://google.com'
|
62
|
+
)
|
63
|
+
request_hash = request.serializable_hash
|
64
|
+
|
93
65
|
expect(request_hash).to include(type: 'get', url: 'http://google.com')
|
94
66
|
end
|
95
67
|
end
|
data/spec/fakes.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
Connection = EmmyMachine::Connection
|
2
|
+
|
3
|
+
module FakeEventMachine
|
4
|
+
extend EmmyMachine::ClassMethods
|
5
|
+
|
6
|
+
def connect(adapter, init)
|
7
|
+
conn = Class.new
|
8
|
+
conn.extend Connection
|
9
|
+
init.call
|
10
|
+
adapter.connected(conn)
|
11
|
+
conn
|
12
|
+
end
|
13
|
+
|
14
|
+
extend self
|
15
|
+
end
|
16
|
+
|
17
|
+
class FakeAdapter
|
18
|
+
attr_accessor :delegate
|
19
|
+
include EmmyHttp::Adapter
|
20
|
+
|
21
|
+
def initialize_connection
|
22
|
+
self.delegate.init! delegate
|
23
|
+
end
|
24
|
+
|
25
|
+
def connected(conn)
|
26
|
+
# replace request with timer
|
27
|
+
EventMachine.add_timer(0) do
|
28
|
+
response = EmmyHttp::Response.new
|
29
|
+
response.headers = {'Content-Type' => 'text/html'}
|
30
|
+
response.status = 200
|
31
|
+
self.delegate.head!(response, delegate, conn)
|
32
|
+
response.body = "OK"
|
33
|
+
self.delegate.success!(delegate.response, delegate, conn)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_a
|
38
|
+
[self, method(:initialize_connection)]
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emmy-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- inre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: event_object
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: emmy-machine
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.7
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.7
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: fibre
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,16 +142,16 @@ files:
|
|
114
142
|
- lib/emmy_http/client/timeouts.rb
|
115
143
|
- lib/emmy_http/model.rb
|
116
144
|
- lib/emmy_http/operation.rb
|
145
|
+
- lib/emmy_http/refines.rb
|
117
146
|
- lib/emmy_http/request.rb
|
118
147
|
- lib/emmy_http/response.rb
|
119
|
-
- lib/emmy_http/server/options.rb
|
120
148
|
- lib/emmy_http/timeout.rb
|
121
149
|
- lib/emmy_http/utils.rb
|
122
150
|
- lib/emmy_http/version.rb
|
123
|
-
-
|
124
|
-
- pkg/emmy-http-0.1.1.gem
|
151
|
+
- spec/emmy_http/model_spec.rb
|
125
152
|
- spec/emmy_http/response_spec.rb
|
126
153
|
- spec/emmy_http_spec.rb
|
154
|
+
- spec/fakes.rb
|
127
155
|
- spec/spec_helper.rb
|
128
156
|
homepage: ''
|
129
157
|
licenses:
|
@@ -148,8 +176,10 @@ rubyforge_project:
|
|
148
176
|
rubygems_version: 2.4.3
|
149
177
|
signing_key:
|
150
178
|
specification_version: 4
|
151
|
-
summary: EmmyHttp
|
179
|
+
summary: EmmyHttp - EventMachine's HTTP Client
|
152
180
|
test_files:
|
181
|
+
- spec/emmy_http/model_spec.rb
|
153
182
|
- spec/emmy_http/response_spec.rb
|
154
183
|
- spec/emmy_http_spec.rb
|
184
|
+
- spec/fakes.rb
|
155
185
|
- spec/spec_helper.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module EmmyHttp
|
2
|
-
class Server::Options
|
3
|
-
include ModelPack::Document
|
4
|
-
|
5
|
-
attribute :chdir, default: Dir.pwd
|
6
|
-
attribute :environment, default: 'development'
|
7
|
-
atrribute :address, default: '0.0.0.0'
|
8
|
-
attribute :port, default: 3434
|
9
|
-
attribute :timeout, default: 30
|
10
|
-
attribute :pid, default: File.join(Dir.pwd, "tmp/pids/server.log")
|
11
|
-
attribute :log, default: File.join(Dir.pwd, "log/server.log")
|
12
|
-
attribute :max_conns, default: 1024
|
13
|
-
attribute :max_persistent_conns, default: 100
|
14
|
-
attribute :require default: []
|
15
|
-
attribute :wait default: 30
|
16
|
-
attribute :fiberpool_size, default: 20
|
17
|
-
attribute :daemonize, default: false
|
18
|
-
end
|
19
|
-
end
|
data/pkg/emmy-http-0.1.0.gem
DELETED
Binary file
|
data/pkg/emmy-http-0.1.1.gem
DELETED
Binary file
|