|
@@ -3,7 +3,7 @@
|
|
|
# Our Rack application to be executed by rackup
|
|
|
class HelloWorld
|
|
|
DEFAULT_HEADERS = {}.tap do |h|
|
|
|
- h['Server'] = SERVER_STRING if SERVER_STRING
|
|
|
+ h[SERVER_HEADER] = SERVER_STRING if SERVER_STRING
|
|
|
|
|
|
h.freeze
|
|
|
end
|
|
@@ -91,29 +91,29 @@ class HelloWorld
|
|
|
case env['PATH_INFO']
|
|
|
when '/json'
|
|
|
# Test type 1: JSON serialization
|
|
|
- ['application/json', JSON.fast_generate(:message=>'Hello, World!')]
|
|
|
+ [JSON_TYPE, JSON.fast_generate(:message=>'Hello, World!')]
|
|
|
when '/db'
|
|
|
# Test type 2: Single database query
|
|
|
- ['application/json', JSON.fast_generate(db)]
|
|
|
+ [JSON_TYPE, JSON.fast_generate(db)]
|
|
|
when '/queries'
|
|
|
# Test type 3: Multiple database queries
|
|
|
- ['application/json', JSON.fast_generate(queries(env))]
|
|
|
+ [JSON_TYPE, JSON.fast_generate(queries(env))]
|
|
|
when '/fortunes'
|
|
|
# Test type 4: Fortunes
|
|
|
- ['text/html; charset=utf-8', fortunes]
|
|
|
+ [HTML_TYPE, fortunes]
|
|
|
when '/updates'
|
|
|
# Test type 5: Database updates
|
|
|
- ['application/json', JSON.fast_generate(updates(env))]
|
|
|
+ [JSON_TYPE, JSON.fast_generate(updates(env))]
|
|
|
when '/plaintext'
|
|
|
# Test type 6: Plaintext
|
|
|
- ['text/plain', 'Hello, World!']
|
|
|
+ [PLAINTEXT_TYPE, 'Hello, World!']
|
|
|
end
|
|
|
|
|
|
[
|
|
|
200,
|
|
|
DEFAULT_HEADERS.merge(
|
|
|
- 'Content-Type'=>content_type,
|
|
|
- 'Date'=>Time.now.httpdate
|
|
|
+ CONTENT_TYPE => content_type,
|
|
|
+ DATE_HEADER => Time.now.httpdate
|
|
|
),
|
|
|
body
|
|
|
]
|