diode 1.3.0 → 1.3.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
  SHA256:
3
- metadata.gz: b8b71e839db24b48761cbd168c49dcd69ba03c9eba9033738f3b6998561dff8f
4
- data.tar.gz: d9fd0af9f07501b19c534fd9209973ad07002b9aef0ec5c00d3163f71f3e3e93
3
+ metadata.gz: b48c0ef0d062a22a1a859065f2320cda02d13c861cc2dc96d5a0f6a44d070a56
4
+ data.tar.gz: 6dba85d23da905543b0f2518c6a18ff7c31dce8741c6ca6126d92bc52719a239
5
5
  SHA512:
6
- metadata.gz: 24da9787c6334cc86c2a586ba05a6330c6640279ae886312d2a480b05477c1a85c80c61366f9fd4ccf458d0d3a6aa236ee846311146d3a2f2274c6cdd2904db2
7
- data.tar.gz: 443d99195550acad9c33740f0f5276c019341824f969a895bcbba69ada0b84324a2de4dea7bb5d57dfc8d2d72f2bf5a968beeb64cf4d5e593437c7c26cf2b4e9
6
+ metadata.gz: '09facf23abbab77b23158dae5b70d66c4d3c58c2c67d82511f9fb10c4cf1e123836d5d767e5a3152e813b7ae75d0388fd63b8f0ab9b4a4317c78d0acfa8729ed'
7
+ data.tar.gz: 70ebbbdea54c6dd15dcfe8af2234f1dd5a3364f6098c40be7ad33fa5ead7d31517557a07246acb65538dbaf8aa0bdf4680474e9078394611a51510855c4ea73c
data/lib/diode/request.rb CHANGED
@@ -50,11 +50,12 @@ class Request
50
50
  headerline, sep, msg = msg.partition("\r\n")
51
51
  while not headerline.strip.empty?
52
52
  key, value = headerline.strip.split(': ')
53
+ key = key.strip.downcase().split(/\b/).collect{|e| e[0].upcase + e[1..-1].downcase}.join("") # title case
54
+ raise(Diode::RequestError.new(400, "duplicate header '#{key}'")) if headers.keys.include?(key)
53
55
  @headers[key] = value
54
56
  headerline, sep, msg = msg.partition("\r\n")
55
57
  end
56
- rescue EOFError
57
- # tolerate missing \r\n at end of request
58
+ rescue EOFError # tolerate missing \r\n at end of request
58
59
  end
59
60
  @cookies = {}
60
61
  if @headers.key?("Cookie")
data/lib/diode/server.rb CHANGED
@@ -48,6 +48,7 @@ class Server
48
48
  # check routing table is sane
49
49
  def validate_routing()
50
50
  newRouting = []
51
+ raise("routing must be an Array") unless @routing.is_a?(Array)
51
52
  @routing.each { |pattern, klass, *args|
52
53
  raise("invalid pattern='#{pattern}' in routing table") unless pattern.is_a?(Regexp)
53
54
  begin
data/lib/diode/static.rb CHANGED
@@ -11,8 +11,8 @@ class Static
11
11
 
12
12
  def serve(request)
13
13
  return Diode::Response.new(405, "Method not allowed", {"Content-type" => "text/plain"}) unless request.method == "GET"
14
- path = Pathname.new(request.path).cleanpath.sub(request.pattern, "") # remove the leading portion matching the mount pattern
15
- filepath = Pathname.new(File.expand_path(path, @root))
14
+ path = Pathname.new(request.path).cleanpath().to_s()
15
+ filepath = Pathname.new(File.expand_path(@root.to_s() + path))
16
16
  filepath = Pathname.new(File.expand_path("index.html", filepath)) if filepath.directory?
17
17
  return Diode::Response.new(404, "<html><body>File not found</body></html>", {"Content-type" => "text/html"}) unless filepath.exist?
18
18
  mimetype = @@mimetypes[filepath.extname[1..-1]] || "application/octet-stream"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diode
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kjell Koda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-17 00:00:00.000000000 Z
11
+ date: 2024-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json