[php-src] master: sapi/cli: support HTTP QUERY method in built-in server (#22615)

Vazha Aptsiauri via GitHub <[email protected]>
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: Vazha Aptsiauri (Afcyy)
Committer: GitHub (web-flow)
Pusher: Girgias
Date: 2026-07-08T15:10:01+01:00

Commit: https://github.com/php/php-src/commit/35881e12982933fd7eaea30da10994e91c84e1e5
Raw diff: https://github.com/php/php-src/commit/35881e12982933fd7eaea30da10994e91c84e1e5.diff

sapi/cli: support HTTP QUERY method in built-in server (#22615)

Co-authored-by: Vazha Aptsiauri <[email protected]>

Changed paths:
  A  sapi/cli/tests/php_cli_server_query_method.phpt
  M  UPGRADING
  M  sapi/cli/php_http_parser.c
  M  sapi/cli/php_http_parser.h


Diff:

diff --git a/UPGRADING b/UPGRADING
index b9c659ccc405..6a1f1b12e4a8 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -297,6 +297,10 @@ PHP 8.6 UPGRADE NOTES
 3. Changes in SAPI modules
 ========================================
 
+- CLI:
+  . The built-in development server now accepts requests using the QUERY HTTP
+    method instead of returning 501 Not Implemented.
+
 ========================================
 4. Deprecated Functionality
 ========================================
diff --git a/sapi/cli/php_http_parser.c b/sapi/cli/php_http_parser.c
index c7c2ad0caaea..ac3c19d5d963 100644
--- a/sapi/cli/php_http_parser.c
+++ b/sapi/cli/php_http_parser.c
@@ -82,6 +82,7 @@ static const char *method_strings[] =
   , "POST"
   , "PUT"
   , "PATCH"
+  , "QUERY"
   , "CONNECT"
   , "OPTIONS"
   , "TRACE"
@@ -521,6 +522,7 @@ size_t php_http_parser_execute (php_http_parser *parser,
           case 'N': parser->method = PHP_HTTP_NOTIFY; break;
           case 'O': parser->method = PHP_HTTP_OPTIONS; break;
           case 'P': parser->method = PHP_HTTP_POST; /* or PROPFIND or PROPPATCH or PUT */ break;
+          case 'Q': parser->method = PHP_HTTP_QUERY; break;
           case 'R': parser->method = PHP_HTTP_REPORT; break;
           case 'S': parser->method = PHP_HTTP_SUBSCRIBE; /* or SEARCH */ break;
           case 'T': parser->method = PHP_HTTP_TRACE; break;
diff --git a/sapi/cli/php_http_parser.h b/sapi/cli/php_http_parser.h
index 345ca405edd0..d7006b6d04d7 100644
--- a/sapi/cli/php_http_parser.h
+++ b/sapi/cli/php_http_parser.h
@@ -79,6 +79,7 @@ enum php_http_method
   , PHP_HTTP_POST
   , PHP_HTTP_PUT
   , PHP_HTTP_PATCH
+  , PHP_HTTP_QUERY
   /* pathological */
   , PHP_HTTP_CONNECT
   , PHP_HTTP_OPTIONS
diff --git a/sapi/cli/tests/php_cli_server_query_method.phpt b/sapi/cli/tests/php_cli_server_query_method.phpt
new file mode 100644
index 000000000000..58ce95bfd1e3
--- /dev/null
+++ b/sapi/cli/tests/php_cli_server_query_method.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Support HTTP QUERY method
+--SKIPIF--
+<?php
+include "skipif.inc";
+?>
+--FILE--
+<?php
+include "php_cli_server.inc";
+php_cli_server_start(<<<'PHP'
+var_dump($_SERVER['REQUEST_METHOD']);
+PHP
+);
+
+$host = PHP_CLI_SERVER_HOSTNAME;
+$fp = php_cli_server_connect();
+
+if (fwrite($fp, <<<HEADER
+QUERY / HTTP/1.1
+Host: {$host}
+
+
+HEADER
+)) {
+    while (!feof($fp)) {
+        echo fgets($fp);
+    }
+}
+
+fclose($fp);
+?>
+--EXPECTF--
+HTTP/1.1 200 OK
+Host: %s
+Date: %s
+Connection: close
+X-Powered-By: %s
+Content-type: text/html; charset=UTF-8
+
+string(5) "QUERY"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.