Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Port to HTTP_Request2

  • Loading branch information...
commit 192a8cc9c5ddbec603dee8800e928c4a37b987ff 1 parent edb421c
Adam Monsen meonkeys authored

Showing 1 changed file with 8 additions and 10 deletions. Show diff stats Hide diff stats

  1. +8 10 CloudFront.php
18 CloudFront.php
@@ -4,7 +4,7 @@
4 4 * A PHP5 class for invalidating Amazon CloudFront objects via its API.
5 5 */
6 6
7   -require_once 'HTTP/Request.php'; // grab with "pear install --onlyreqdeps HTTP_Request"
  7 +require_once 'HTTP/Request2.php'; // grab with "pear install --onlyreqdeps HTTP_Request2"
8 8
9 9
10 10 class CloudFront {
@@ -50,21 +50,19 @@ function invalidate($keys, $debug=false){
50 50 $body .= "<CallerReference>".time()."</CallerReference>";
51 51 $body .= "</InvalidationBatch>";
52 52 // make and send request
53   - $req = & new HTTP_Request($requestUrl);
54   - $req->setMethod("POST");
55   - $req->addHeader("Date", $date);
56   - $req->addHeader("Authorization", $this->makeKey($date));
57   - $req->addHeader("Content-Type", "text/xml");
  53 + $req = & new HTTP_Request2($requestUrl, HTTP_Request2::METHOD_POST);
  54 + $req->setHeader("Date", $date);
  55 + $req->setHeader("Authorization", $this->makeKey($date));
  56 + $req->setHeader("Content-Type", "text/xml");
58 57 $req->setBody($body);
59   - $response = $req->sendRequest();
60   - $this->responseCode = $req->getResponseCode();
  58 + $response = $req->send();
  59 + $this->responseCode = $response->getStatus();
61 60 if ($debug==true){
62 61 $er = array();
63 62 array_push($er, "CloudFront: Invalidating Object: $key");
64 63 array_push($er, $requestUrl);
65 64 array_push($er, "body: $body");
66   - array_push($er, "response: $response");
67   - array_push($er, "response string: " . $req->getResponseBody());
  65 + array_push($er, "response: " . $response->getBody());
68 66 array_push($er, "");
69 67 array_push($er, "response code: " . $this->responseCode);
70 68 array_push($er, "");

0 comments on commit 192a8cc

Please sign in to comment.
Something went wrong with that request. Please try again.