php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51918 Phar::webPhar() does not handle requests sent through PUT and DELETE method
Submitted: 2010-05-26 10:40 UTC Modified: 2011-08-29 20:35 UTC
Votes:6
Avg. Score:4.5 ± 0.8
Reproduced:5 of 5 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: max dot romanovsky at gmail dot com Assigned:
Status: Closed Package: PHAR related
PHP Version: 5.3.2 OS: FreeBSD
Private report: No CVE-ID: None
 [2010-05-26 10:40 UTC] max dot romanovsky at gmail dot com
Description:
------------
Phar::webPhar() does not handle requests sent through PUT and DELETE request method.

Test script:
---------------
PUT /REST/foo HTTP/1.1
host: example.com
Content-Length: 2
12


HTTP/1.1 200 OK
Server: nginx/0.8.36
Date: Tue, 25 May 2010 14:01:42 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/5.3.2

0


Patches

phar_restful (last revision 2012-01-11 18:08 UTC by f at overridelogic dot com)

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-29 19:06 UTC] bjori@php.net
It seems quite intentional. It only supports GET and POST, not PUT, DELETE, HEAD, 
...
 [2011-08-29 20:35 UTC] max dot romanovsky at gmail dot com
But we can't build RESTful application that will be packaged in Phar and started 
using Phar::webPhar().
Or there is some other intention to handle only GET and POST methods?
 [2012-01-11 18:10 UTC] f at overridelogic dot com
I ran into the same problem with the same results with 5.3.9 on Ubuntu, and created a patch (phar_restful.patch) to support PUT, DELETE and OPTIONS. He are my results after applying it:


Test script
-----------
phar = new Phar('temp.phar');
$phar['index.php'] = '<?php var_dump(file_get_contents("php://input"), $_SERVER["REQUEST_METHOD"]); ?>';


Test requests
--------------
PUT /temp.phar/index.php HTTP/1.1
Host: localhost
Content-Length: 11

Hello World


DELETE /temp.phar/index.php HTTP/1.1
Host: localhost
Content-Length: 11

Hello World


OPTIONS /temp.phar/index.php HTTP/1.1
Host: localhost
Content-Length: 11

Hello World



Actual result
-------------
HTTP/1.1 200 OK
Date: Wed, 11 Jan 2012 15:39:36 GMT
Server: Apache/2.2.16 (Ubuntu)
X-Powered-By: PHP/5.3.9
Vary: Accept-Encoding
Content-Length: 41
Content-Type: text/html

string(11) "Hello World"
string(3) "PUT"


HTTP/1.1 200 OK
Date: Wed, 11 Jan 2012 15:39:38 GMT
Server: Apache/2.2.16 (Ubuntu)
X-Powered-By: PHP/5.3.9
Vary: Accept-Encoding
Content-Length: 44
Content-Type: text/html

string(11) "Hello World"
string(6) "DELETE"


HTTP/1.1 200 OK
Date: Wed, 11 Jan 2012 15:39:42 GMT
Server: Apache/2.2.16 (Ubuntu)
X-Powered-By: PHP/5.3.9
Vary: Accept-Encoding
Content-Length: 45
Content-Type: text/html

string(11) "Hello World"
string(7) "OPTIONS"
 [2014-07-12 11:49 UTC] cweiske@php.net
Still happens with PHP 5.6.0RC2 and git as of today.
 [2017-05-02 12:47 UTC] ab@php.net
Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c0c08719117ee6116073a2c65a6840213403e65b
Log: Fixed bug #51918 Phar::webPhar() does not handle requests sent through PUT and DELETE method
 [2017-05-02 12:47 UTC] ab@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 10:01:30 2024 UTC