From 6b23bbb92b37c77a8c732eadd8afa531a973c8e2 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Mon, 29 Aug 2016 11:59:45 +0000 Subject: [PATCH] Comments: Add support for all HTTP protocol versions when returning a 405 from `wp-comments-post.php`. Fixes #37863 Props tnash git-svn-id: https://develop.svn.wordpress.org/trunk@38432 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-comments-post.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wp-comments-post.php b/src/wp-comments-post.php index 4e9f1fcfb0..2c421d327a 100644 --- a/src/wp-comments-post.php +++ b/src/wp-comments-post.php @@ -6,8 +6,13 @@ */ if ( 'POST' != $_SERVER['REQUEST_METHOD'] ) { + $protocol = $_SERVER['SERVER_PROTOCOL']; + if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) { + $protocol = 'HTTP/1.0'; + } + header('Allow: POST'); - header('HTTP/1.1 405 Method Not Allowed'); + header("$protocol 405 Method Not Allowed"); header('Content-Type: text/plain'); exit; }