PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 260805
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v260805
260917 260913 260909 260829 260814 260805 110710 110731 110812 110815 110912 110913 110915 110926 110927 111002 111003 111011 111017 111029 111105 111206 111216 111220 120213 All 189 releases
s2member / src / includes / externals / aweber / curl_response.php

curl_response.php in s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions 260805, at src/includes/externals/aweber/curl_response.php

53 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // @codingStandardsIgnoreFile
3
4 # CurlResponse
5 #
6 # Author Sean Huber - shuber@huberry.com
7 # Date May 2008
8 #
9 # A basic CURL wrapper for PHP
10 #
11 # See the README for documentation/examples or http://php.net/curl for more information
12 # about the libcurl extension for PHP -- http://github.com/shuber/curl/tree/master
13 #
14
15 class CurlResponse
16 {
17 public $body = '';
18 public $headers = array();
19
20 public function __construct($response)
21 {
22 # Extract headers from response
23 $pattern = '#HTTP/\d\.\d.*?$.*?\r\n\r\n#ims';
24 preg_match_all($pattern, $response, $matches);
25 $headers = explode("\r\n", str_replace("\r\n\r\n", '', array_pop($matches[0])));
26
27 # Extract the version and status from the first header
28 $version_and_status = array_shift($headers);
29 preg_match('#HTTP/(\d\.\d)\s(\d\d\d)\s(.*)#', $version_and_status, $matches);
30 $this->headers['Http-Version'] = $matches[1];
31 $this->headers['Status-Code'] = $matches[2];
32 $this->headers['Status'] = $matches[2].' '.$matches[3];
33
34 # Convert headers into an associative array
35 foreach ($headers as $header) {
36 preg_match('#(.*?)\:\s(.*)#', $header, $matches);
37 $this->headers[$matches[1]] = $matches[2];
38 }
39
40 # Remove the headers from the response body
41 $this->body = preg_replace($pattern, '', $response);
42 }
43
44 public function __toString()
45 {
46 return $this->body;
47 }
48
49 public function headers(){
50 return $this->headers;
51 }
52 }
53