waitress-core 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/waitress/restful/restbuilder.rb +15 -7
- data/lib/waitress/server.rb +15 -14
- data/lib/waitress/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0a6a44766a6e5162cf5cccf453b6087490f597c
|
4
|
+
data.tar.gz: 7b1501a57e628d4ecbe5ab16ea2eb37f589f60f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee66d99a6d9b14f19d94dfe9202271fd428edbf4affecc1471e73447bdfbac765926e8f0625e57bea7c8b3755ecd0c54013ca6201931730cdaeeaa0a032a7a85
|
7
|
+
data.tar.gz: 569f5985b4eed195b6588035bd5fa486b99d23ce8544fb6ea55253883b1b93e989d7a1bfe0b9b04ffb43ff0502606328cc777ffa7587494e8134737c7c97e72d
|
@@ -6,6 +6,7 @@ module Waitress
|
|
6
6
|
require 'yaml'
|
7
7
|
|
8
8
|
attr_accessor :priority
|
9
|
+
attr_accessor :regex
|
9
10
|
|
10
11
|
SUPPORTED_FORMATS = [:json, :scon, :yaml, :yml]
|
11
12
|
|
@@ -23,15 +24,16 @@ module Waitress
|
|
23
24
|
else
|
24
25
|
buildRe << enumerations.join("|")
|
25
26
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
if optional
|
28
|
+
buildRe << "/)?"
|
29
|
+
else
|
30
|
+
buildRe << ")/"
|
31
|
+
end
|
30
32
|
|
31
33
|
buildRe
|
32
34
|
end
|
33
35
|
|
34
|
-
Waitress::REST.new(Regexp.new(a), &call)
|
36
|
+
Waitress::REST.new(Regexp.new("^#{a}$"), &call)
|
35
37
|
end
|
36
38
|
|
37
39
|
def initialize regex, &call
|
@@ -40,8 +42,14 @@ module Waitress
|
|
40
42
|
@priority = 200
|
41
43
|
end
|
42
44
|
|
45
|
+
def getpath request
|
46
|
+
path = request.path
|
47
|
+
path += "/" unless path.end_with? "/"
|
48
|
+
path
|
49
|
+
end
|
50
|
+
|
43
51
|
def respond? request, vhost
|
44
|
-
(request
|
52
|
+
(getpath(request) =~ @regex) != nil
|
45
53
|
end
|
46
54
|
|
47
55
|
def encode_format content_hash, request, response, type
|
@@ -61,7 +69,7 @@ module Waitress
|
|
61
69
|
end
|
62
70
|
|
63
71
|
def serve request, response, client, vhost
|
64
|
-
match = request.
|
72
|
+
match = getpath(request).match @regex
|
65
73
|
|
66
74
|
form = :json
|
67
75
|
if (request.get_query.include? "format")
|
data/lib/waitress/server.rb
CHANGED
@@ -76,17 +76,8 @@ module Waitress
|
|
76
76
|
@processes.times do
|
77
77
|
processes << gofork {
|
78
78
|
while true
|
79
|
-
|
80
|
-
|
81
|
-
gofork do # Makes sure requires etc don't get triggered across requests
|
82
|
-
handle_client client
|
83
|
-
end.wait
|
84
|
-
client.close rescue nil
|
85
|
-
rescue => e
|
86
|
-
puts "Server Error: #{e} (Fix This!)"
|
87
|
-
puts e.backtrace
|
88
|
-
client.close rescue nil
|
89
|
-
end
|
79
|
+
client = serv.accept
|
80
|
+
connect_client(client)
|
90
81
|
end
|
91
82
|
}
|
92
83
|
end
|
@@ -97,8 +88,20 @@ module Waitress
|
|
97
88
|
processes
|
98
89
|
end
|
99
90
|
|
91
|
+
def connect_client client
|
92
|
+
begin
|
93
|
+
gofork do # Makes sure requires etc don't get triggered across requests
|
94
|
+
handle_client client
|
95
|
+
end.wait
|
96
|
+
client.close rescue nil
|
97
|
+
rescue => e
|
98
|
+
puts "Server Error: #{e} (Fix This!)"
|
99
|
+
puts e.backtrace
|
100
|
+
client.close rescue nil
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
100
104
|
def handle_client client_socket
|
101
|
-
# pro = gofork do
|
102
105
|
begin
|
103
106
|
data = client_socket.readpartial(8192)
|
104
107
|
nparsed = 0
|
@@ -123,9 +126,7 @@ module Waitress
|
|
123
126
|
puts "Client Error: #{e}"
|
124
127
|
puts e.backtrace
|
125
128
|
end
|
126
|
-
# end
|
127
129
|
client_socket.close rescue nil
|
128
|
-
# pro.wait
|
129
130
|
end
|
130
131
|
|
131
132
|
def build_request headers, client_socket
|
data/lib/waitress/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waitress-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaci Brunning
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|