Initiate a request to the AYAH web service through curl or using a socket
if the system does not have curl available.
@param string $hostname
@param string $path
@param array $fields
@return string|mixed
185711
protected function doHttpsPost($hostname, $path, $fields)
    {
        $result = '';
        $fields_string = '';

        //Url encode the string
        foreach($fields as $key => $value)
        {
            if (is_array($value)) {
                if (! empty($value)) {
                    foreach ($value as $k => $v) {
                        $fields_string .= $key . '['. $k .']=' . $v . '&';
                    }
                } else {
                  $fields_string .= $key . '=&';
                }
            } else {
                $fields_string .= $key.'='.$value.'&';
            }
        }

        rtrim($fields_string,'&');

        // cURL or something else
        if(function_exists('curl_init'))
        {
            $curlsession = curl_init();
            curl_setopt($curlsession, CURLOPT_URL, 'https://' . $hostname . $path);
            curl_setopt($curlsession, CURLOPT_POST,count($fields));
            curl_setopt($curlsession, CURLOPT_POSTFIELDS,$fields_string);
            curl_setopt($curlsession, CURLOPT_RETURNTRANSFER,1);
            curl_setopt($curlsession, CURLOPT_SSL_VERIFYHOST,0);
            curl_setopt($curlsession, CURLOPT_SSL_VERIFYPEER,false);

            $result = curl_exec($curlsession);
        }
        else
        {
            // Build a header
            $http_request  = "POST $path HTTP/1.1\r\n";
            $http_request .= "Host: $hostname\r\n";
            $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
            $http_request .= "Content-Length: " . strlen($fields_string) . "\r\n";
            $http_request .= "User-Agent: AreYouAHuman/PHP " . $this->version . "\r\n";
            $http_request .= "Connection: Close\r\n";
            $http_request .= "\r\n";
            $http_request .= $fields_string ."\r\n";

            $result = '';
            $errno = $errstr = "";
            $fs = fsockopen("ssl://" . $hostname, 443, $errno, $errstr, 10);
            if( false == $fs ) {
                error_log('Could not open socket');
            } else {
                fwrite($fs, $http_request);
                while (!feof($fs)) {
                    $result .= fgets($fs, 4096);
                }

                $result = explode("\r\n\r\n", $result, 2);
                $result = $result[1];
            }
        }

        return $result;
    }
159708
private function getUri(string $path, string $host = null, array $query = []): UriInterface
    {
        $host = $host ? new Uri($host) : $this->host;
        $uri = UriResolver::resolve($host, new Uri($path));

        if ($query) {
            $uri = $uri->withQuery(\http_build_query(
                $query,
                '',
                '&',
                \PHP_QUERY_RFC3986
            ));
        }

        return $uri;
    }
883278
protected function buildHttpRequest($path, $hostname)
    {
        $r = array();
        $r[] = "GET {$path} HTTP/1.1";
        $r[] = "Host: {$hostname}";
        $r[] = "Connection: Close";
        $r[] = "User-Agent: HttpAdapter PHP-Library";
        $r[] = "\r\n";

        return implode("\r\n", $r);
    }
548354
protected function get(string $pathName, array $params = [], $headers = []): \Generator
    {
        $url = $this->buildUrl($pathName, $params);

        return $this->httpClient->request('GET', $url, $headers, null, [
            'timeout' => 60
        ]);
    }
1042882
public static String doPut(String host, String path,
                               Map<String, String> headers,
                               Map<String, String> queries) throws Exception {
        return doPut(host, path, headers, queries, "");
    }
951724
public function fields($fields, $path = null)
    {
        if (is_null($fields)) return;

        $path = $path ?: __DIR__.'/../tmp-fields.txt';
        $fields = preg_split('/, ?/', $fields);
        $arrayFields = array();

        foreach($fields as $pair)
        {
            list($key, $val) = preg_split('/ ?: ?/', $pair);
            $arrayFields[$key] = $val;
        }

        return $this->file->put($path, json_encode($arrayFields));
    }
676295
private function makeRequest($path, array $attributes)
    {
        $data = json_encode($attributes);

        return new Request(
            'POST', $path, [
            'Content-Type' => 'application/json',
            'Accept'       => 'application/json',
            'Merchant'     => $this->getMerchantId(),
            'Signature'    => $this->generateSignature($data),
        ], $data
        );
    }
936014
public function addPathHeader(string $name, $path)
    {
        return $this->add(new PathHeader($name, $path instanceof Address ? $path : new Address($path)));
    }
469961
public function request($path, $body, $httpMethod = 'GET', array $headers = [], array $options = [])
	{
		$request = $this->createRequest($httpMethod, $path, $body, $headers);

		try {
			$response = $this->client->send($request, $options);
		} catch (\LogicException $e) {
			throw new \ErrorException($e->getMessage(), $e->getCode(), $e);
		} catch (\RuntimeException $e) {
			throw new \RuntimeException($e->getMessage(), $e->getCode(), $e);
		}

		$this->lastRequest  = $request;
		$this->lastResponse = $response;

		return $response;
	}
876147
private function get($path, $params = null, $headers = null)
    {
        return $this->run($path, array('method' => 'get', 'params' => $params, 'headers' => $headers));
    }
1110625
public function get(string $path, array $parameters = [], array $requestHeaders = []): ResponseInterface
    {
        if (count($parameters) > 0) {
            $path .= '?' . http_build_query($parameters);
        }

        $response = $this->httpClient->sendRequest(
            $this->requestBuilder->create('GET', $path, $requestHeaders)
        );

        $statusCode = $response->getStatusCode();
        if ($statusCode !== 200) {
            $errorResponse = $response->getBody()->__toString();
            $errorMessage = !empty($errorResponse) ? $errorResponse : "Invalid Auspost API response.";

            throw new EndpointServiceError($errorMessage);
        }

        return $response;
    }
1035521
public function post($path, $guestSpaceId = null, $filename = null): string
    {
        $options = ['multipart' => [self::createMultipart($path, $filename)]];
        $this->changeLocale();

        /** @var JsonStream $stream */
        $stream = $this->client
            ->post(KintoneApi::generateUrl('file.json', $guestSpaceId), $options)
            ->getBody();

        return $stream->jsonSerialize()['fileKey'];
    }
838455
def get(self, path):
        
        # Generate token
        service_name = gssapi.Name('HTTP@{0}'.format(self.url.netloc),
                                   gssapi.NameType.hostbased_service)
        ctx = gssapi.SecurityContext(usage="initiate", name=service_name)
        data = b64encode(ctx.step()).decode()

        # Make the connection
        connection = httplib.HTTPSConnection(self.url.netloc, 443)
        log.debug("GET {0}".format(path))
        connection.putrequest("GET", path)
        connection.putheader("Authorization", "Negotiate {0}".format(data))
        connection.putheader("Referer", self.url_string)
        connection.endheaders()

        # Perform the request, convert response into lines
        response = connection.getresponse()
        if response.status != 200:
            raise ReportError(
                "Failed to fetch tickets: {0}".format(response.status))
        lines = response.read().decode("utf8").strip().split("\n")[1:]
        log.debug("Tickets fetched:")
        log.debug(pretty(lines))
        return lines
410069
public function handle($path, $expires = 3600, $host_name = '', $use_ssl = false)
    {
        if (! method_exists($this->filesystem, 'getAdapter')) {
            return false;
        }

        if (! method_exists($this->filesystem->getAdapter(), 'getSignedDownloadUrl')) {
            return false;
        }

        return $this->filesystem->getAdapter()->getSignedDownloadUrl($path, $expires, $host_name, $use_ssl);
    }
693009
private function get($path, array $params = [])
    {
        $request = $this->createHttpGetRequest($this->buildUrl($path), $params);

        $response = $this->httpClient->sendRequest($request);

        return $this->parseResponse($response, $request);
    }
559618
protected function post($path, array $parameters = [], $requestHeaders = [])
    {
        $path = $this->preparePath($path);

        $body = null;
        if (!empty($parameters)) {
            $body = $this->streamFactory->createStream(QueryStringBuilder::build($parameters));
            $requestHeaders['Content-Type'] = 'application/x-www-form-urlencoded';
        }

        try {
            $response = $this->client->getHttpClient()->post($path, $requestHeaders, $body);
        } catch (HttpException $e) {
            (new ApiExceptionHandler($e))->handle();
        }

        return ResponseFormatter::getContent($response);
    }
982552
protected function serverRequest($path, $context)
	{
		if (strpos($path, '/') === 0)
		{
			$path = substr($path, 1);
		}

		$url = sprintf('http://%s/%s', $this->serverUrl, $path);

		$context = stream_context_create($context);
		$result = @file_get_contents($url, false, $context);

		if ($result === false)
		{
			throw new ClientException('Failed connecting to ' . $url);
		}

		if (($result = json_decode($result)) === false)
		{
			throw new ClientException("Failed decoding json response from server");
		}

		if (empty($result))
		{
			throw new ClientException("Did not receive a valid client instance");
		}

		return $result;
	}