Permalink
Browse files

bail out early on favicon requests

  • Loading branch information...
1 parent 4fd8bab commit dc77e908c6f272c0ab34f8d34a7923b0fe727f5b @rtomayko rtomayko committed Jun 22, 2010
Showing with 16 additions and 4 deletions.
  1. +2 −3 bin/shotgun
  2. +14 −1 lib/shotgun.rb
View
@@ -109,13 +109,15 @@ require 'rack/lint'
require 'rack/commonlogger'
require 'rack/showexceptions'
+require 'shotgun'
server = Rack::Handler.get(server) || Rack::Handler.default
app_wrapper =
lambda do |inner_app|
case env
when 'development'
Rack::Builder.new {
+ use Shotgun::SkipFavicon
use Rack::CommonLogger, STDERR unless server.name =~ /CGI/
use Rack::ShowExceptions
use Rack::Lint
@@ -130,9 +132,6 @@ app_wrapper =
inner_app
end
end
-
-
-require 'shotgun'
app = Shotgun.new(config, app_wrapper)
base_url = "http://#{options[:Host]}:#{options[:Port]}"
View
@@ -44,7 +44,7 @@ def proceed_as_parent
[
500,
{'Content-Type'=>'text/html;charset=utf-8'},
- [format_error(error, message)]
+ [format_error(error, backtrace)]
]
else
fail "unexpected response: #{result.inspect}"
@@ -127,4 +127,17 @@ def spec_body(body)
def enable_copy_on_write
GC.copy_on_write_friendly = true if GC.respond_to?(:copy_on_write_friendly=)
end
+
+ class SkipFavicon < Struct.new(:app)
+ def call(env)
+ if env['PATH_INFO'] == '/favicon.ico'
+ [404, {
+ 'Content-Type' => 'image/png',
+ 'Cache-Control' => 'public, max-age=100000000000'
+ }, []]
+ else
+ app.call(env)
+ end
+ end
+ end
end

0 comments on commit dc77e90

Please sign in to comment.