From d5a07d08314e4164b9f88f23ff68f633a518c4ce Mon Sep 17 00:00:00 2001 From: Marcos Piccinini Date: Wed, 10 May 2017 17:31:30 -0300 Subject: [PATCH] Update for rack 2+ Rack deprecated Rack::Utils#bytesize --- lib/barista/server.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/barista/server.rb b/lib/barista/server.rb index 3bc18df..e207038 100644 --- a/lib/barista/server.rb +++ b/lib/barista/server.rb @@ -79,7 +79,7 @@ def forbidden body = "Forbidden\n" [403, { 'Content-Type' => 'text/plain', - 'Content-Length' => Rack::Utils.bytesize(body).to_s, + 'Content-Length' => body.bytesize.to_s, 'X-Cascade' => 'pass' }, [body]] end @@ -90,7 +90,7 @@ def not_found body = "Not Found\n" [404, { 'Content-Type' => 'text/plain', - 'Content-Length' => Rack::Utils.bytesize(body).to_s, + 'Content-Length' => body.bytesize.to_s, 'X-Cascade' => 'pass' }, [body]] end @@ -99,7 +99,7 @@ def not_found def response_for_text(content, content_type = 'text/javascript', modified_at = nil) headers = { 'Content-Type' => content_type, - 'Content-Length' => Rack::Utils.bytesize(content).to_s, + 'Content-Length' => content.bytesize.to_s, 'Cache-Control' => "public, max-age=#{CACHE_FOR_SECONDS}" } headers.merge!('Last-Modified' => modified_at.httpdate) unless modified_at.nil?