From f51c9ed2abe5c68211bb3736be5f70b1fe2c9ec0 Mon Sep 17 00:00:00 2001 From: M.Gergo Date: Fri, 8 Mar 2019 21:20:34 +0100 Subject: további rendrakás --- .../share/facebook/Http/GraphRawResponse.php | 137 ----------------- .../share/facebook/Http/RequestBodyInterface.php | 39 ----- .../share/facebook/Http/RequestBodyMultipart.php | 170 --------------------- .../share/facebook/Http/RequestBodyUrlEncoded.php | 55 ------- 4 files changed, 401 deletions(-) delete mode 100644 mayor-orig/www/include/share/facebook/Http/GraphRawResponse.php delete mode 100644 mayor-orig/www/include/share/facebook/Http/RequestBodyInterface.php delete mode 100644 mayor-orig/www/include/share/facebook/Http/RequestBodyMultipart.php delete mode 100644 mayor-orig/www/include/share/facebook/Http/RequestBodyUrlEncoded.php (limited to 'mayor-orig/www/include/share/facebook/Http') diff --git a/mayor-orig/www/include/share/facebook/Http/GraphRawResponse.php b/mayor-orig/www/include/share/facebook/Http/GraphRawResponse.php deleted file mode 100644 index d1a7241c..00000000 --- a/mayor-orig/www/include/share/facebook/Http/GraphRawResponse.php +++ /dev/null @@ -1,137 +0,0 @@ -httpResponseCode = (int)$httpStatusCode; - } - - if (is_array($headers)) { - $this->headers = $headers; - } else { - $this->setHeadersFromString($headers); - } - - $this->body = $body; - } - - /** - * Return the response headers. - * - * @return array - */ - public function getHeaders() - { - return $this->headers; - } - - /** - * Return the body of the response. - * - * @return string - */ - public function getBody() - { - return $this->body; - } - - /** - * Return the HTTP response code. - * - * @return int - */ - public function getHttpResponseCode() - { - return $this->httpResponseCode; - } - - /** - * Sets the HTTP response code from a raw header. - * - * @param string $rawResponseHeader - */ - public function setHttpResponseCodeFromHeader($rawResponseHeader) - { - preg_match('|HTTP/\d\.\d\s+(\d+)\s+.*|', $rawResponseHeader, $match); - $this->httpResponseCode = (int)$match[1]; - } - - /** - * Parse the raw headers and set as an array. - * - * @param string $rawHeaders The raw headers from the response. - */ - protected function setHeadersFromString($rawHeaders) - { - // Normalize line breaks - $rawHeaders = str_replace("\r\n", "\n", $rawHeaders); - - // There will be multiple headers if a 301 was followed - // or a proxy was followed, etc - $headerCollection = explode("\n\n", trim($rawHeaders)); - // We just want the last response (at the end) - $rawHeader = array_pop($headerCollection); - - $headerComponents = explode("\n", $rawHeader); - foreach ($headerComponents as $line) { - if (strpos($line, ': ') === false) { - $this->setHttpResponseCodeFromHeader($line); - } else { - list($key, $value) = explode(': ', $line, 2); - $this->headers[$key] = $value; - } - } - } -} diff --git a/mayor-orig/www/include/share/facebook/Http/RequestBodyInterface.php b/mayor-orig/www/include/share/facebook/Http/RequestBodyInterface.php deleted file mode 100644 index 1c03f4fd..00000000 --- a/mayor-orig/www/include/share/facebook/Http/RequestBodyInterface.php +++ /dev/null @@ -1,39 +0,0 @@ -params = $params; - $this->files = $files; - $this->boundary = $boundary ?: uniqid(); - } - - /** - * @inheritdoc - */ - public function getBody() - { - $body = ''; - - // Compile normal params - $params = $this->getNestedParams($this->params); - foreach ($params as $k => $v) { - $body .= $this->getParamString($k, $v); - } - - // Compile files - foreach ($this->files as $k => $v) { - $body .= $this->getFileString($k, $v); - } - - // Peace out - $body .= "--{$this->boundary}--\r\n"; - - return $body; - } - - /** - * Get the boundary - * - * @return string - */ - public function getBoundary() - { - return $this->boundary; - } - - /** - * Get the string needed to transfer a file. - * - * @param string $name - * @param FacebookFile $file - * - * @return string - */ - private function getFileString($name, FacebookFile $file) - { - return sprintf( - "--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"%s\r\n\r\n%s\r\n", - $this->boundary, - $name, - $file->getFileName(), - $this->getFileHeaders($file), - $file->getContents() - ); - } - - /** - * Get the string needed to transfer a POST field. - * - * @param string $name - * @param string $value - * - * @return string - */ - private function getParamString($name, $value) - { - return sprintf( - "--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n%s\r\n", - $this->boundary, - $name, - $value - ); - } - - /** - * Returns the params as an array of nested params. - * - * @param array $params - * - * @return array - */ - private function getNestedParams(array $params) - { - $query = http_build_query($params, null, '&'); - $params = explode('&', $query); - $result = []; - - foreach ($params as $param) { - list($key, $value) = explode('=', $param, 2); - $result[urldecode($key)] = urldecode($value); - } - - return $result; - } - - /** - * Get the headers needed before transferring the content of a POST file. - * - * @param FacebookFile $file - * - * @return string - */ - protected function getFileHeaders(FacebookFile $file) - { - return "\r\nContent-Type: {$file->getMimetype()}"; - } -} diff --git a/mayor-orig/www/include/share/facebook/Http/RequestBodyUrlEncoded.php b/mayor-orig/www/include/share/facebook/Http/RequestBodyUrlEncoded.php deleted file mode 100644 index c1e35f43..00000000 --- a/mayor-orig/www/include/share/facebook/Http/RequestBodyUrlEncoded.php +++ /dev/null @@ -1,55 +0,0 @@ -params = $params; - } - - /** - * @inheritdoc - */ - public function getBody() - { - return http_build_query($this->params, null, '&'); - } -} -- cgit v1.2.3