Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make Rack::Lobster set Content-Length

  • Loading branch information...
commit 4a04950f249d9efaa6c4f59f454ebafb3ddf5ebb 1 parent 7af1377
@chneukirchen authored
Showing with 13 additions and 13 deletions.
  1. +13 −13 lib/rack/lobster.rb
View
26 lib/rack/lobster.rb
@@ -22,11 +22,11 @@ class Lobster
href = "?flip"
end
- [200, {"Content-Type" => "text/html"},
- ["<title>Lobstericious!</title>",
- "<pre>", lobster, "</pre>",
- "<a href='#{href}'>flip!</a>"]
- ]
+ content = ["<title>Lobstericious!</title>",
+ "<pre>", lobster, "</pre>",
+ "<a href='#{href}'>flip!</a>"]
+ length = content.inject(0) { |a,e| a+e.size }.to_s
+ [200, {"Content-Type" => "text/html", "Content-Length" => length}, content]
}
def call(env)
@@ -43,14 +43,14 @@ def call(env)
href = "?flip=left"
end
- Response.new.finish do |res|
- res.write "<title>Lobstericious!</title>"
- res.write "<pre>"
- res.write lobster
- res.write "</pre>"
- res.write "<p><a href='#{href}'>flip!</a></p>"
- res.write "<p><a href='?flip=crash'>crash!</a></p>"
- end
+ res = Response.new
+ res.write "<title>Lobstericious!</title>"
+ res.write "<pre>"
+ res.write lobster
+ res.write "</pre>"
+ res.write "<p><a href='#{href}'>flip!</a></p>"
+ res.write "<p><a href='?flip=crash'>crash!</a></p>"
+ res.finish
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.