File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -317,6 +317,12 @@ def get_type_from_request_body(request_body)
317317 serve_from_s3 ( sitemap )
318318 end
319319
320+ post "/sitemaps/*" do
321+ headers = { "Allow" => "GET" }
322+ body = { message : "Method Not Allowed: Use GET to access the sitemap." } . to_json
323+ halt ( 405 , headers , body )
324+ end
325+
320326 def serve_from_s3 ( key )
321327 o = Services . s3_client . get_object ( bucket : ENV [ "AWS_S3_SITEMAPS_BUCKET_NAME" ] , key :)
322328
Original file line number Diff line number Diff line change 5555 end
5656 end
5757 end
58+
59+ describe "post /sitemaps/*" do
60+ it "returns a 405 error message" do
61+ post "/sitemaps/server/anything/stuff.php"
62+ expect ( last_response . status ) . to eq ( 405 )
63+ expect ( last_response . headers [ "Allow" ] ) . to eq ( "GET" )
64+ expect ( last_response . body ) . to eq ( { message : "Method Not Allowed: Use GET to access the sitemap." } . to_json )
65+ end
66+ end
5867end
You can’t perform that action at this time.
0 commit comments