You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by li...@apache.org on 2010/02/02 01:16:36 UTC

svn commit: r905470 - in /incubator/shindig/trunk/php/src: common/sample/BasicRemoteContentFetcher.php gadgets/MakeRequest.php

Author: lindner
Date: Tue Feb  2 00:16:36 2010
New Revision: 905470

URL: http://svn.apache.org/viewvc?rev=905470&view=rev
Log:
SHINDIG-1269 | Patch from Thiago Arrais | Support for all request method types

Modified:
    incubator/shindig/trunk/php/src/common/sample/BasicRemoteContentFetcher.php
    incubator/shindig/trunk/php/src/gadgets/MakeRequest.php

Modified: incubator/shindig/trunk/php/src/common/sample/BasicRemoteContentFetcher.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/sample/BasicRemoteContentFetcher.php?rev=905470&r1=905469&r2=905470&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/common/sample/BasicRemoteContentFetcher.php (original)
+++ incubator/shindig/trunk/php/src/common/sample/BasicRemoteContentFetcher.php Tue Feb  2 00:16:36 2010
@@ -210,9 +210,15 @@
       $outHeaders[] = "User-Agent: " . BasicRemoteContentFetcher::USER_AGENT;
       curl_setopt($request->handle, CURLOPT_HTTPHEADER, $outHeaders);
     }
+    $method = $request->getMethod();
     if ($request->isPost()) {
       curl_setopt($request->handle, CURLOPT_POST, 1);
       curl_setopt($request->handle, CURLOPT_POSTFIELDS, $request->getPostBody());
+    } else if ($method == 'DELETE' || $method == 'HEAD' || $method == 'PUT') {
+      curl_setopt($request->handle, CURLOPT_CUSTOMREQUEST, $method);
+      if ($method == "PUT") {
+        curl_setopt($request->handle, CURLOPT_POSTFIELDS, $request->getPostBody());
+      }
     }
   }
 

Modified: incubator/shindig/trunk/php/src/gadgets/MakeRequest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/MakeRequest.php?rev=905470&r1=905469&r2=905470&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/MakeRequest.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/MakeRequest.php Tue Feb  2 00:16:36 2010
@@ -159,9 +159,12 @@
       // (since RemoteContentRquest checks if its false)
       // so the request to POST is still honored
       $request = new RemoteContentRequest($params->getHref(), null, $params->getRequestBody());
-    } else {
+    } else if ($method == 'DELETE' || $method == 'GET' || $method == 'HEAD') {
       $request = new RemoteContentRequest($params->getHref());
+    } else {
+      throw new Exception("Invalid HTTP method.");
     }
+    $request->setMethod($method);
     if ($signer) {
       switch ($params->getAuthz()) {
         case 'SIGNED':