]> granicus.if.org Git - php/commitdiff
Fixed bug #51918 Phar::webPhar() does not handle requests sent through PUT and DELETE...
authorChristian Weiske <cweiske@cweiske.de>
Fri, 21 Apr 2017 19:20:00 +0000 (21:20 +0200)
committerAnatol Belski <ab@php.net>
Tue, 2 May 2017 12:44:47 +0000 (14:44 +0200)
phar: Support DELETE, HEAD and PUT HTTP methods in Phar::webPhar

Up to now only GET and POST requests could be handled with Phar::webPhar(),
which is insufficient for today's REST APIs.
This patch expands the list of supported HTTP methods.

ext/phar/phar_object.c

index 1799268297ada46a14261b7717420830a5e01516..b363fd01a95806a6dbb44caea4e4cc30111fa886 100644 (file)
@@ -582,7 +582,18 @@ PHP_METHOD(Phar, webPhar)
        }
 
        /* retrieve requested file within phar */
-       if (!(SG(request_info).request_method && SG(request_info).request_uri && (!strcmp(SG(request_info).request_method, "GET") || !strcmp(SG(request_info).request_method, "POST")))) {
+       if (!(SG(request_info).request_method
+          && SG(request_info).request_uri
+          && (!strcmp(SG(request_info).request_method, "GET")
+           || !strcmp(SG(request_info).request_method, "POST")
+           || !strcmp(SG(request_info).request_method, "DELETE")
+           || !strcmp(SG(request_info).request_method, "HEAD")
+           || !strcmp(SG(request_info).request_method, "OPTIONS")
+           || !strcmp(SG(request_info).request_method, "PATCH")
+           || !strcmp(SG(request_info).request_method, "PUT")
+          )
+         )
+      ) {
                return;
        }