1 | <?php |
||
24 | class CurlClient implements ClientInterface |
||
25 | { |
||
26 | /** |
||
27 | * {@inheritdoc} |
||
28 | */ |
||
29 | public function makeCall( |
||
75 | |||
76 | /** |
||
77 | * Parse header string from Curl request and returns an array. Based on: |
||
78 | * http://php.net/manual/en/function.http-parse-headers.php#112986 |
||
79 | * http://php.net/manual/en/function.http-parse-headers.php#112987 |
||
80 | * |
||
81 | * @param string $headerString |
||
82 | * |
||
83 | * @return array |
||
84 | */ |
||
85 | private function parseHttpHeaders($headerString) |
||
86 | { |
||
87 | $headers = array(); |
||
88 | $key = ''; |
||
89 | |||
90 | foreach (explode("\n", $headerString) as $i => $h) { |
||
91 | $h = explode(':', $h, 2); |
||
92 | |||
93 | if (isset($h[1])) { |
||
94 | if (!isset($headers[$h[0]])) { |
||
95 | $headers[$h[0]] = trim($h[1]); |
||
96 | } elseif (is_array($headers[$h[0]])) { |
||
97 | $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); |
||
98 | } else { |
||
99 | $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); |
||
100 | } |
||
101 | |||
102 | $key = $h[0]; |
||
103 | } else { |
||
104 | if (substr($h[0], 0, 1) == "\t") { |
||
105 | $headers[$key] .= "\r\n\t" . trim($h[0]); |
||
106 | } elseif (!$key) { |
||
107 | $headers[0] = trim($h[0]); |
||
108 | } |
||
109 | } |
||
110 | } |
||
111 | |||
112 | return $headers; |
||
113 | } |
||
114 | |||
115 | /** |
||
116 | * Convert headers in key => value format, to cURL accepted header format. |
||
117 | * |
||
118 | * @param string[] $headers Headers in key => value format, if key is |
||
119 | * numeric only the value will be stored in the |
||
120 | * new array. |
||
121 | * |
||
122 | * @return string[] |
||
123 | */ |
||
124 | private function processRequestHeaders(array $headers) |
||
140 | } |
||
141 |