Skip to content

Commit dd60aad

Browse files
authored
Merge pull request #1135 from tdiary/revert-rack3
Revert Rack 3 support
2 parents b98d074 + 3ce0c5b commit dd60aad

File tree

11 files changed

+47
-62
lines changed

11 files changed

+47
-62
lines changed

Gemfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
source 'https://rubygems.org'
22

3-
gem 'rack'
4-
gem 'rackup'
3+
gem 'rack', '< 3'
54
gem 'hikidoc'
65
gem 'fastimage'
76
gem 'emot'

Gemfile.lock

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ GEM
2525
docile (1.4.0)
2626
emot (0.0.4)
2727
thor
28-
faraday (2.8.1)
29-
base64
30-
faraday-net_http (>= 2.0, < 3.1)
31-
ruby2_keywords (>= 0.0.4)
32-
faraday-net_http (3.0.2)
28+
faraday (2.9.0)
29+
faraday-net_http (>= 2.0, < 3.2)
30+
faraday-net_http (3.1.0)
31+
net-http
3332
fastimage (2.3.0)
3433
hikidoc (0.1.0)
3534
jasmine (2.99.0)
@@ -51,6 +50,8 @@ GEM
5150
mime-types-data (~> 3.2015)
5251
mime-types-data (3.2024.0206)
5352
mini_mime (1.1.5)
53+
net-http (0.4.1)
54+
uri
5455
net-imap (0.4.10)
5556
date
5657
net-protocol
@@ -64,23 +65,21 @@ GEM
6465
racc (~> 1.4)
6566
nokogiri (1.16.2-x86_64-linux)
6667
racc (~> 1.4)
67-
octokit (4.25.1)
68+
octokit (8.1.0)
69+
base64
6870
faraday (>= 1, < 3)
6971
sawyer (~> 0.9)
7072
phantomjs (2.1.1.0)
7173
pit (0.0.7)
7274
power_assert (2.0.3)
7375
public_suffix (5.0.4)
7476
racc (1.7.3)
75-
rack (3.0.9.1)
77+
rack (2.2.8.1)
7678
rack-test (2.1.0)
7779
rack (>= 1.3)
7880
racksh (1.0.1)
7981
rack (>= 1.0)
8082
rack-test (>= 0.5)
81-
rackup (2.1.0)
82-
rack (>= 3)
83-
webrick (~> 1.8)
8483
rake (13.1.0)
8584
redcarpet (3.6.0)
8685
regexp_parser (2.9.0)
@@ -98,7 +97,6 @@ GEM
9897
diff-lcs (>= 1.2.0, < 2.0)
9998
rspec-support (~> 3.13.0)
10099
rspec-support (3.13.1)
101-
ruby2_keywords (0.0.5)
102100
rubyzip (2.3.2)
103101
sawyer (0.9.2)
104102
addressable (>= 2.3.5)
@@ -126,6 +124,7 @@ GEM
126124
timeout (0.4.1)
127125
tins (1.32.1)
128126
sync
127+
uri (0.13.0)
129128
webrick (1.8.1)
130129
websocket (1.2.10)
131130
xpath (3.2.0)
@@ -148,9 +147,8 @@ DEPENDENCIES
148147
mime-types
149148
octokit
150149
pit
151-
rack
150+
rack (< 3)
152151
racksh
153-
rackup
154152
rake
155153
redcarpet
156154
rexml
@@ -162,8 +160,5 @@ DEPENDENCIES
162160
test-unit
163161
webrick
164162

165-
RUBY VERSION
166-
ruby 3.2.3p157
167-
168163
BUNDLED WITH
169164
2.4.22

lib/aws/pa_api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def get_items(asin, locale)
5353
"X-Amz-Date" => time_stamp,
5454
"X-Amz-Content-Sha256" => OpenSSL::Digest::SHA256.hexdigest(payload),
5555
"Authorization" => authorization,
56-
"content-type" => "application/json; charset=utf-8"
56+
"Content-Type" => "application/json; charset=utf-8"
5757
}
5858
uri = URI("https://#{MARKETS[locale].host}/paapi5/getitems")
5959
http = Net::HTTP.new(uri.host, uri.port)

lib/tdiary/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def call( env )
5353
rescue Exception => e
5454
body = ["#{e.class}: #{e}\n"]
5555
body << e.backtrace.join("\n")
56-
[500, {'content-type' => 'text/plain'}, body]
56+
[500, {'Content-Type' => 'text/plain'}, body]
5757
end
5858
end
5959

lib/tdiary/dispatcher.rb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ class << self
3131
# stolen from Rack::Handler::CGI.send_headers
3232
def send_headers(status, headers)
3333
begin
34-
headers['type'] = headers.delete('content-type')
34+
headers['type'] = headers.delete('Content-Type')
3535
$stdout.print CGI.new.header({'Status'=>status}.merge(headers))
3636
rescue EOFError
3737
charset = headers.delete('charset')
38-
headers['content-type'] ||= headers.delete( 'type' )
39-
headers['content-type'] += "; charset=#{charset}" if charset
38+
headers['Content-Type'] ||= headers.delete( 'type' )
39+
headers['Content-Type'] += "; charset=#{charset}" if charset
4040
$stdout.print headers.map{|k,v| "#{k}: #{v}\r\n"}.join << "\r\n"
4141
end
4242
$stdout.flush
@@ -71,12 +71,7 @@ def adopt_rack_request_to_plain_old_tdiary_style( env )
7171
req = TDiary::Request.new( env )
7272
req.params # fill params to tdiary_request
7373
$RACK_ENV = req.env
74-
# Rack 3.x has been removed rack.input rewinding
75-
begin
76-
env["rack.input"].instance_variable_get(:@input).rewind
77-
rescue
78-
env["rack.input"].rewind
79-
end
74+
env["rack.input"].rewind
8075
fake_stdin_as_params
8176
req
8277
end

lib/tdiary/dispatcher/index_main.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,43 @@ def run
2121

2222
begin
2323
head = {
24-
'content-type' => 'text/html; charset=UTF-8',
25-
'vary' => 'User-Agent'
24+
'Content-Type' => 'text/html; charset=UTF-8',
25+
'Vary' => 'User-Agent'
2626
}
2727
head['status'] = status if status
2828
body = ''
2929
head['Last-Modified'] = CGI::rfc1123_date( tdiary.last_modified )
3030

3131
if request.head?
32-
head['pragma'] = 'no-cache'
33-
head['cache-control'] = 'no-cache'
32+
head['Pragma'] = 'no-cache'
33+
head['Cache-Control'] = 'no-cache'
3434
return TDiary::Response.new( '', 200, head )
3535
else
3636
require 'openssl'
3737
body = tdiary.eval_rhtml
38-
head['etag'] = %Q["#{OpenSSL::Digest::SHA256.hexdigest( body )}"]
39-
if ENV['HTTP_IF_NONE_MATCH'] == head['etag'] and request.get? then
38+
head['ETag'] = %Q["#{OpenSSL::Digest::SHA256.hexdigest( body )}"]
39+
if ENV['HTTP_IF_NONE_MATCH'] == head['ETag'] and request.get? then
4040
head['status'] = CGI::HTTP_STATUS['NOT_MODIFIED']
4141
else
4242
head['charset'] = conf.encoding
43-
head['content-length'] = body.bytesize.to_s
43+
head['Content-Length'] = body.bytesize.to_s
4444
end
45-
head['pragma'] = 'no-cache'
46-
head['cache-control'] = 'no-cache'
47-
head['x-frame-options'] = conf.x_frame_options if conf.x_frame_options
45+
head['Pragma'] = 'no-cache'
46+
head['Cache-Control'] = 'no-cache'
47+
head['X-Frame-Options'] = conf.x_frame_options if conf.x_frame_options
4848
head['cookie'] = tdiary.cookies if tdiary.cookies.size > 0
4949
TDiary::Response.new( body, ::TDiary::Dispatcher.extract_status_for_legacy_tdiary( head ), head )
5050
end
5151
rescue TDiary::NotFound
5252
body = %Q[
5353
<h1>404 Not Found</h1>
5454
<div>#{' ' * 500}</div>]
55-
TDiary::Response.new( body, 404, { 'content-type' => 'text/html' } )
55+
TDiary::Response.new( body, 404, { 'Content-Type' => 'text/html' } )
5656
end
5757
rescue TDiary::ForceRedirect
5858
head = {
5959
#'Location' => $!.path
60-
'content-type' => 'text/html',
60+
'Content-Type' => 'text/html',
6161
}
6262
body = %Q[
6363
<html>

lib/tdiary/dispatcher/update_main.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ def run
2020
head = {}; body = ''
2121
body = tdiary.eval_rhtml
2222
head = {
23-
'content-type' => 'text/html; charset=UTF-8',
23+
'Content-Type' => 'text/html; charset=UTF-8',
2424
'charset' => conf.encoding,
25-
'content-length' => body.bytesize.to_s,
26-
'vary' => 'User-Agent',
27-
'x-frame-options' => 'SAMEORIGIN'
25+
'Content-Length' => body.bytesize.to_s,
26+
'Vary' => 'User-Agent',
27+
'X-Frame-Options' => 'SAMEORIGIN'
2828
}
2929
body = ( request.head? ? '' : body )
3030
TDiary::Response.new( body, 200, head )
3131
rescue TDiary::ForceRedirect
3232
head = {
3333
#'Location' => $!.path
34-
'content-type' => 'text/html',
34+
'Content-Type' => 'text/html',
3535
}
3636
body = %Q[
3737
<html>

lib/tdiary/rack/auth/basic.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def call(env)
2222
begin
2323
@authenticator.call(env)
2424
rescue PasswordFileNotFound => e
25-
[403, {"content-type" => "text/plain"}, [e.message]]
25+
[403, {"Content-Type" => "text/plain"}, [e.message]]
2626
end
2727
end
2828
end

lib/tdiary/rack/auth/omniauth/authorization.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ def login(env)
3232
req = ::Rack::Request.new(env)
3333
env['rack.session']['tdiary.auth.redirect'] = "#{req.base_url}#{req.fullpath}"
3434
redirect = File.join("#{req.base_url}#{req.path}", "#{::OmniAuth.config.path_prefix}/#{@provider}")
35-
[302, {'content-type' => 'text/plain', 'location' => redirect}, []]
35+
[302, {'Content-Type' => 'text/plain', 'Location' => redirect}, []]
3636
end
3737

3838
def logout(env)
3939
env['rack.session']['user_id'] = nil
4040
end
4141

4242
def forbidden
43-
[403, {'content-type' => 'text/plain'}, ['forbidden']]
43+
[403, {'Content-Type' => 'text/plain'}, ['forbidden']]
4444
end
4545

4646
def callback(env)
@@ -51,7 +51,7 @@ def callback(env)
5151
env['rack.session']['auth'] = auth
5252
env['REMOTE_USER'] = "#{auth.uid}@#{auth.provider}"
5353
redirect = env['rack.session']['tdiary.auth.redirect'] || '/'
54-
[302, {'content-type' => 'text/plain', 'location' => redirect}, []]
54+
[302, {'Content-Type' => 'text/plain', 'Location' => redirect}, []]
5555
end
5656

5757
def authenticate?(env)

lib/tdiary/rack/valid_request_path.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ def call( env )
1717

1818
body = "Not Found: #{env['PATH_INFO']}"
1919
if env["REQUEST_METHOD"] == "HEAD"
20-
[404, {'content-type' => 'text/plain', 'content-length' => body.length.to_s}, []]
20+
[404, {'Content-Type' => 'text/plain', 'Content-Length' => body.length.to_s}, []]
2121
else
22-
[404, {'content-type' => 'text/plain'}, [body]]
22+
[404, {'Content-Type' => 'text/plain'}, [body]]
2323
end
2424
end
2525
end

0 commit comments

Comments
 (0)