rack 2.2.3 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rack might be problematic. Click here for more details.

Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +164 -69
  3. data/CONTRIBUTING.md +53 -47
  4. data/MIT-LICENSE +1 -1
  5. data/README.md +287 -0
  6. data/Rakefile +40 -7
  7. data/SPEC.rdoc +166 -125
  8. data/contrib/LICENSE.md +7 -0
  9. data/contrib/logo.webp +0 -0
  10. data/lib/rack/auth/abstract/handler.rb +3 -1
  11. data/lib/rack/auth/abstract/request.rb +3 -1
  12. data/lib/rack/auth/digest/md5.rb +1 -131
  13. data/lib/rack/auth/digest/nonce.rb +1 -54
  14. data/lib/rack/auth/digest/params.rb +1 -54
  15. data/lib/rack/auth/digest/request.rb +1 -43
  16. data/lib/rack/auth/digest.rb +256 -0
  17. data/lib/rack/body_proxy.rb +3 -1
  18. data/lib/rack/builder.rb +60 -42
  19. data/lib/rack/cascade.rb +2 -0
  20. data/lib/rack/chunked.rb +16 -13
  21. data/lib/rack/common_logger.rb +24 -16
  22. data/lib/rack/conditional_get.rb +18 -15
  23. data/lib/rack/constants.rb +62 -0
  24. data/lib/rack/content_length.rb +12 -16
  25. data/lib/rack/content_type.rb +8 -5
  26. data/lib/rack/deflater.rb +40 -26
  27. data/lib/rack/directory.rb +9 -3
  28. data/lib/rack/etag.rb +14 -21
  29. data/lib/rack/events.rb +4 -0
  30. data/lib/rack/file.rb +2 -0
  31. data/lib/rack/files.rb +15 -17
  32. data/lib/rack/head.rb +9 -8
  33. data/lib/rack/headers.rb +154 -0
  34. data/lib/rack/lint.rb +764 -684
  35. data/lib/rack/lock.rb +2 -5
  36. data/lib/rack/logger.rb +2 -0
  37. data/lib/rack/media_type.rb +1 -1
  38. data/lib/rack/method_override.rb +4 -0
  39. data/lib/rack/mime.rb +8 -0
  40. data/lib/rack/mock.rb +1 -271
  41. data/lib/rack/mock_request.rb +166 -0
  42. data/lib/rack/mock_response.rb +124 -0
  43. data/lib/rack/multipart/generator.rb +7 -5
  44. data/lib/rack/multipart/parser.rb +120 -62
  45. data/lib/rack/multipart/uploaded_file.rb +4 -0
  46. data/lib/rack/multipart.rb +20 -41
  47. data/lib/rack/null_logger.rb +9 -0
  48. data/lib/rack/query_parser.rb +80 -44
  49. data/lib/rack/recursive.rb +2 -0
  50. data/lib/rack/reloader.rb +0 -2
  51. data/lib/rack/request.rb +187 -89
  52. data/lib/rack/response.rb +131 -61
  53. data/lib/rack/rewindable_input.rb +24 -5
  54. data/lib/rack/runtime.rb +7 -6
  55. data/lib/rack/sendfile.rb +30 -25
  56. data/lib/rack/show_exceptions.rb +15 -2
  57. data/lib/rack/show_status.rb +17 -7
  58. data/lib/rack/static.rb +8 -8
  59. data/lib/rack/tempfile_reaper.rb +15 -4
  60. data/lib/rack/urlmap.rb +3 -1
  61. data/lib/rack/utils.rb +199 -170
  62. data/lib/rack/version.rb +9 -4
  63. data/lib/rack.rb +5 -76
  64. data/rack.gemspec +6 -6
  65. metadata +19 -31
  66. data/README.rdoc +0 -306
  67. data/bin/rackup +0 -5
  68. data/contrib/rack.png +0 -0
  69. data/contrib/rack.svg +0 -150
  70. data/contrib/rack_logo.svg +0 -164
  71. data/lib/rack/core_ext/regexp.rb +0 -14
  72. data/lib/rack/handler/cgi.rb +0 -59
  73. data/lib/rack/handler/fastcgi.rb +0 -100
  74. data/lib/rack/handler/lsws.rb +0 -61
  75. data/lib/rack/handler/scgi.rb +0 -71
  76. data/lib/rack/handler/thin.rb +0 -36
  77. data/lib/rack/handler/webrick.rb +0 -129
  78. data/lib/rack/handler.rb +0 -104
  79. data/lib/rack/lobster.rb +0 -70
  80. data/lib/rack/server.rb +0 -466
  81. data/lib/rack/session/abstract/id.rb +0 -523
  82. data/lib/rack/session/cookie.rb +0 -203
  83. data/lib/rack/session/memcache.rb +0 -10
  84. data/lib/rack/session/pool.rb +0 -85
@@ -0,0 +1,154 @@
1
+ module Rack
2
+ # Rack::Headers is a Hash subclass that downcases all keys. It's designed
3
+ # to be used by rack applications that don't implement the Rack 3 SPEC
4
+ # (by using non-lowercase response header keys), automatically handling
5
+ # the downcasing of keys.
6
+ class Headers < Hash
7
+ def self.[](*items)
8
+ if items.length % 2 != 0
9
+ if items.length == 1 && items.first.is_a?(Hash)
10
+ new.merge!(items.first)
11
+ else
12
+ raise ArgumentError, "odd number of arguments for Rack::Headers"
13
+ end
14
+ else
15
+ hash = new
16
+ loop do
17
+ break if items.length == 0
18
+ key = items.shift
19
+ value = items.shift
20
+ hash[key] = value
21
+ end
22
+ hash
23
+ end
24
+ end
25
+
26
+ def [](key)
27
+ super(downcase_key(key))
28
+ end
29
+
30
+ def []=(key, value)
31
+ super(key.downcase.freeze, value)
32
+ end
33
+ alias store []=
34
+
35
+ def assoc(key)
36
+ super(downcase_key(key))
37
+ end
38
+
39
+ def compare_by_identity
40
+ raise TypeError, "Rack::Headers cannot compare by identity, use regular Hash"
41
+ end
42
+
43
+ def delete(key)
44
+ super(downcase_key(key))
45
+ end
46
+
47
+ def dig(key, *a)
48
+ super(downcase_key(key), *a)
49
+ end
50
+
51
+ def fetch(key, *default, &block)
52
+ key = downcase_key(key)
53
+ super
54
+ end
55
+
56
+ def fetch_values(*a)
57
+ super(*a.map!{|key| downcase_key(key)})
58
+ end
59
+
60
+ def has_key?(key)
61
+ super(downcase_key(key))
62
+ end
63
+ alias include? has_key?
64
+ alias key? has_key?
65
+ alias member? has_key?
66
+
67
+ def invert
68
+ hash = self.class.new
69
+ each{|key, value| hash[value] = key}
70
+ hash
71
+ end
72
+
73
+ def merge(hash, &block)
74
+ dup.merge!(hash, &block)
75
+ end
76
+
77
+ def reject(&block)
78
+ hash = dup
79
+ hash.reject!(&block)
80
+ hash
81
+ end
82
+
83
+ def replace(hash)
84
+ clear
85
+ update(hash)
86
+ end
87
+
88
+ def select(&block)
89
+ hash = dup
90
+ hash.select!(&block)
91
+ hash
92
+ end
93
+
94
+ def to_proc
95
+ lambda{|x| self[x]}
96
+ end
97
+
98
+ def transform_values(&block)
99
+ dup.transform_values!(&block)
100
+ end
101
+
102
+ def update(hash, &block)
103
+ hash.each do |key, value|
104
+ self[key] = if block_given? && include?(key)
105
+ block.call(key, self[key], value)
106
+ else
107
+ value
108
+ end
109
+ end
110
+ self
111
+ end
112
+ alias merge! update
113
+
114
+ def values_at(*keys)
115
+ keys.map{|key| self[key]}
116
+ end
117
+
118
+ # :nocov:
119
+ if RUBY_VERSION >= '2.5'
120
+ # :nocov:
121
+ def slice(*a)
122
+ h = self.class.new
123
+ a.each{|k| h[k] = self[k] if has_key?(k)}
124
+ h
125
+ end
126
+
127
+ def transform_keys(&block)
128
+ dup.transform_keys!(&block)
129
+ end
130
+
131
+ def transform_keys!
132
+ hash = self.class.new
133
+ each do |k, v|
134
+ hash[yield k] = v
135
+ end
136
+ replace(hash)
137
+ end
138
+ end
139
+
140
+ # :nocov:
141
+ if RUBY_VERSION >= '3.0'
142
+ # :nocov:
143
+ def except(*a)
144
+ super(*a.map!{|key| downcase_key(key)})
145
+ end
146
+ end
147
+
148
+ private
149
+
150
+ def downcase_key(key)
151
+ key.is_a?(String) ? key.downcase : key
152
+ end
153
+ end
154
+ end