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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5fa1729728798da3d7a4ec0949db1a3fe2deae3
4
- data.tar.gz: 667594fb143c6d05c2ce4b158f3b35eb388aadf2
3
+ metadata.gz: d0a6a44766a6e5162cf5cccf453b6087490f597c
4
+ data.tar.gz: 7b1501a57e628d4ecbe5ab16ea2eb37f589f60f9
5
5
  SHA512:
6
- metadata.gz: 83b1ecfba256a594a6e99b7610656257dfdb83445f889ab907e952c3757c7745e447da388e8be16335f62d483f1c88c013d2c306b23be2f1335b0b762654ed3a
7
- data.tar.gz: 2fe5debcbbc9770416491d0a876d5190e7d6ab802858ed10654dac67b9f033d327d24fe32be8612e2954433a88704dc9cfee05e09e03acbb3c3259d136a9f52c
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
- buildRe << ")"
27
- buildRe << "?" if optional
28
- buildRe << "/"
29
- buildRe << "?" if optional
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.uri =~ @regex) != nil
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.uri.match @regex
72
+ match = getpath(request).match @regex
65
73
 
66
74
  form = :json
67
75
  if (request.get_query.include? "format")
@@ -76,17 +76,8 @@ module Waitress
76
76
  @processes.times do
77
77
  processes << gofork {
78
78
  while true
79
- begin
80
- client = serv.accept
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
@@ -1,3 +1,3 @@
1
1
  module Waitress
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
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.0
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-04 00:00:00.000000000 Z
11
+ date: 2015-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler