78 public static function failure($code, $err =
'Unknown', $uri =
'', $method =
'', $extra =
'') {
84 throw new \HPCloud\Transport\ForbiddenException($err);
86 throw new \HPCloud\Transport\UnauthorizedException($err);
88 throw new \HPCloud\Transport\FileNotFoundException($err .
" ($uri)");
90 throw new \HPCloud\Transport\MethodNotAllowedException($err .
" ($method $uri)");
92 throw new \HPCloud\Transport\ConflictException($err);
94 throw new \HPCloud\Transport\LengthRequiredException($err);
96 throw new \HPCloud\Transport\UnprocessableEntityException($err);
98 throw new \HPCloud\Transport\LockedException($err);
100 throw new \HPCloud\Transport\ServerException($err);
102 throw new \HPCloud\Exception($err);
114 public function __construct($handle, $metadata, $headers = NULL) {
150 return $this->handle;
177 $max = $this->
header(
'Content-Length', NULL);
178 if (isset($this->
metadata[
'unread_bytes']) && isset($max)) {
179 while (!feof($this->handle) && strlen($out) < $max) {
180 $out .= fread($this->handle, 8192);
188 $out = stream_get_contents($this->handle);
193 fclose($this->handle);
213 return $this->metadata;
249 return $this->headers;
292 return $this->message;
305 return $this->protocol;
323 $ret = array_shift($headerArray);
324 $responseLine = preg_split(
'/\s/', $ret);
326 $count = count($headerArray);
328 $this->code = (int) $responseLine[1];
329 $this->message = $responseLine[2];
336 if ($this->code == 100) {
344 for ($i = 0; $i < $count; ++$i) {
345 list(
$name, $value) = explode(
':', $headerArray[$i], 2);
346 $name = filter_var(
$name, FILTER_SANITIZE_STRING);
347 $value = filter_var(trim($value), FILTER_SANITIZE_STRING);
348 $buffer[
$name] = $value;