FIX: error in response body to blocked crawlers, showing 500 Internal Server Error with status of 403

This commit is contained in:
Neil Lalonde 2018-09-14 15:39:24 -04:00
parent b87a089822
commit 526ffc4966
2 changed files with 3 additions and 2 deletions

View File

@ -201,7 +201,7 @@ module Middleware
if helper.blocked_crawler?
env["discourse.request_tracker.skip"] = true
return [403, {}, "Crawler is not allowed!"]
return [403, {}, ["Crawler is not allowed!"]]
end
if helper.should_force_anonymous?

View File

@ -167,7 +167,7 @@ describe Middleware::AnonymousCache::Helper do
"PATH_INFO" => path,
"REQUEST_PATH" => path
}.merge(options[:headers]))
@status = middleware.call(@env).first
@status, @response_header, @response = middleware.call(@env)
end
it "applies whitelisted_crawler_user_agents correctly" do
@ -184,6 +184,7 @@ describe Middleware::AnonymousCache::Helper do
}
expect(@status).to eq(403)
expect(@response).to be_an(Array)
get '/', headers: non_crawler
expect(@status).to eq(200)