mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 05:22:43 +08:00
FIX: error in response body to blocked crawlers, showing 500 Internal Server Error with status of 403
This commit is contained in:
@ -201,7 +201,7 @@ module Middleware
|
|||||||
|
|
||||||
if helper.blocked_crawler?
|
if helper.blocked_crawler?
|
||||||
env["discourse.request_tracker.skip"] = true
|
env["discourse.request_tracker.skip"] = true
|
||||||
return [403, {}, "Crawler is not allowed!"]
|
return [403, {}, ["Crawler is not allowed!"]]
|
||||||
end
|
end
|
||||||
|
|
||||||
if helper.should_force_anonymous?
|
if helper.should_force_anonymous?
|
||||||
|
@ -167,7 +167,7 @@ describe Middleware::AnonymousCache::Helper do
|
|||||||
"PATH_INFO" => path,
|
"PATH_INFO" => path,
|
||||||
"REQUEST_PATH" => path
|
"REQUEST_PATH" => path
|
||||||
}.merge(options[:headers]))
|
}.merge(options[:headers]))
|
||||||
@status = middleware.call(@env).first
|
@status, @response_header, @response = middleware.call(@env)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "applies whitelisted_crawler_user_agents correctly" do
|
it "applies whitelisted_crawler_user_agents correctly" do
|
||||||
@ -184,6 +184,7 @@ describe Middleware::AnonymousCache::Helper do
|
|||||||
}
|
}
|
||||||
|
|
||||||
expect(@status).to eq(403)
|
expect(@status).to eq(403)
|
||||||
|
expect(@response).to be_an(Array)
|
||||||
|
|
||||||
get '/', headers: non_crawler
|
get '/', headers: non_crawler
|
||||||
expect(@status).to eq(200)
|
expect(@status).to eq(200)
|
||||||
|
Reference in New Issue
Block a user