aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/webrick_server.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/railties/lib/webrick_server.rb b/railties/lib/webrick_server.rb
index ba0541e7c6..4a73872ba3 100644
--- a/railties/lib/webrick_server.rb
+++ b/railties/lib/webrick_server.rb
@@ -109,6 +109,8 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
)
header, body = extract_header_and_body(data)
+
+ set_charset(header)
assign_status(res, header)
res.cookies.concat(header.delete('set-cookie'))
header.each { |key, val| res[key] = val.join(", ") }
@@ -138,6 +140,14 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
return header, body
end
+
+ def set_charset(header)
+ ct = header["content-type"]
+ if ct.any? { |x| x =~ /^text\// } && ! ct.any? { |x| x =~ /charset=/ }
+ ch = @server_options[:charset] || "UTF-8"
+ ct.find { |x| x =~ /^text\// } << ("; charset=" + ch)
+ end
+ end
def assign_status(res, header)
if /^(\d+)/ =~ header['status'][0]