@param string $path
@param array $file
@param array $extraHeaders
@return Response

@see https://tech.yandex.com/disk/doc/dg/reference/put-docpage/
490733
public function uploadFile($path = '', $file = null, $extraHeaders = null)
    {
        if (file_exists($file['path'])) {
            $headers = [
                'Content-Length' => (string)$file['size']
            ];
            $finfo = finfo_open(FILEINFO_MIME);
            $mime = finfo_file($finfo, $file['path']);
            $parts = explode(";", $mime);
            $headers['Content-Type'] = $parts[0];
            $headers['Etag'] = md5_file($file['path']);
            $headers['Sha256'] = hash_file('sha256', $file['path']);
            $headers = isset($extraHeaders) ? array_merge($headers, $extraHeaders) : $headers;

            return $this->sendRequest(
                'PUT',
                $path . $file['name'],
                [
                    'headers' => $headers,
                    'body' => fopen($file['path'], 'rb'),
                    'expect' => true
                ]
            );
        }
    }
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;
    }
435822
public function Index($ExtraPaths = NULL) {
      
      $FileMasks = array(
         sprintf(self::LOOKUP_CLASS_MASK, '*'),
         sprintf(self::LOOKUP_INTERFACE_MASK, '*')
      );
      
      $ExtraPathsRemove = NULL;
      if (!is_null($ExtraPaths)) {
         $ExtraPathsRemove = array();
         foreach ($ExtraPaths as $PathOpts) {
            $ExtraPath = GetValue('path', $PathOpts);
            if (array_key_exists($ExtraPath, $this->Paths)) continue;
            
            $ExtraPathsRemove[] = $ExtraPath;
            $ExtraOptions = $this->BuildOptions;
            $ExtraOptions['SplitTopic'] = GetValue('topic', $PathOpts);
            $this->AddPath($ExtraPath, $ExtraOptions);
         }
      }
      
      foreach ($this->Paths as $Path => $PathOptions) {

         $Recursive = GetValue('recursive', $PathOptions);
         $Files = $this->FindFiles($Path, $FileMasks, $Recursive);
         if ($Files === FALSE) continue;
         
         foreach ($Files as $File) {
            $SplitTopic = GetValue('topic', $PathOptions, self::TOPIC_DEFAULT);
            
            $ProvidedClass = $this->GetClassNameFromFile($File);
            if ($ProvidedClass) {
               $this->Map[$SplitTopic][$ProvidedClass] = $File;
               $this->MapInfo['dirty'] = TRUE;
            }
               
//            $ProvidesClasses = $this->Investigate($File);
//            if ($ProvidesClasses === FALSE) continue;
//            
//            foreach ($ProvidesClasses as $ProvidedClass) {
//               $ProvidedClass = strtolower($ProvidedClass);
//               $this->Map[$SplitTopic][$ProvidedClass] = $File;
//               $this->MapInfo['dirty'] = TRUE;
//            }
         }
      }
      
      // Save
      $this->Shutdown();
      
      if (!is_null($ExtraPathsRemove))
         foreach ($ExtraPathsRemove as $RemPath)
            unset($this->Paths[$RemPath]);
   }
755794
public static function Make($path, $extras=array(), $sep="/")
	{
		$ext = "";

		if (sizeof($extras) > 0)
			foreach ($extras as $e)
				$ext .= (string) $e . $sep;


		/* dont seperate if no extras were provided */

		if ($ext != "")
			return $path . $sep . $ext;
		

		return $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;
	}
84197
protected function doGet(string $path, array $parameters = [], array $headers = [])
    {
        if (0 < \count($parameters)) {
            $path .= '?'.\http_build_query($parameters);
        }

        $request = $this
            ->getInstapushClient()
            ->getRequestFactory()
            ->createRequest('GET', $path, $headers);

        $this->setRequest($request);

        $response = $this
            ->getInstapushClient()
            ->getHttpClient()
            ->sendRequest($request);

        $this->setResponse($response);

        return $this;
    }
1214715
public function post($path, array $parameters = [], array $headers = [], $body = null)
	{
		$this->setQuery($parameters);
		$this->setHeaders($headers);
		if ($body instanceof BodyMultipart) {
			$this->setMultipart($body);
		} elseif (is_array($body)) {
			$this->setFormParams($body);
		}

		return  $this->client->request('POST', $path, $this->headers);
	}
507881
public function put($path, $params = []){
        $json = json_encode($params);
        
        return $this->_call('PUT', $path, $json);
    }
1147256
private function doRequest($path, $headers = [])
    {
        if (!$this->isAvailable()) {
            throw new NotAvailableException('Service not available.');
        }

        if ($this->loadBalance !== null) {
            $uri = $this->loadBalance->getUri($this->serviceName);
            $this->zendClient->setUri($uri);
        }
        if ($this->appendPath && strlen($path) > 0 && $this->zendClient->getUri()->getPath() != '/') {
            $path = $this->zendClient->getUri()->getPath() . $path;
        }
        $this->zendClient->getUri()->setPath($path);

        $this->zendClient->getRequest()->getHeaders()->addHeaders($headers);

        if (!$this->zendClient->getRequest()->getHeaders()->has('X-Request-Id')) {
            $this->addRequestId();
        }

        $this->addRequestName($this->serviceName);

        $this->getEventManager()->trigger('request.pre', $this);

        $this->responseTime = 0;

        try {
            $requestTime = microtime(true);

            $zendHttpResponse = $this->zendClient->send();

            $this->responseTime = (float) sprintf('%.2f', (microtime(true) - $requestTime) * 1000);

            $this->addRequestTime($this->responseTime);

            $response = new Response($this->zendClient, $zendHttpResponse, $this->depth);
            $this->reportSuccess();
        } catch (RuntimeException $ex) {
            $this->reportFailure();
            $this->getEventManager()->trigger('request.fail', $this, $ex);
            throw new RuntimeException($ex->getMessage(), $ex->getCode(), $ex);
        } catch (\Exception $ex) {
            $this->reportFailure();
            $this->getEventManager()->trigger('request.fail', $this, $ex);
            throw new RuntimeException($ex->getMessage(), 500, $ex);
        }

        $this->getEventManager()->trigger('request.post', $this);

        $content = $response->getContent();

        return $content;
    }
375371
protected function httpPut(string $path, array $parameters = [], array $requestHeaders = []): ResponseInterface
    {
        try {
            $response = $this->httpClient->sendRequest(
                $this->requestBuilder->create('PUT', $path, $requestHeaders, $this->createRequestBody($parameters))
            );
        } catch (Psr18\NetworkExceptionInterface $e) {
            throw HttpServerException::networkError($e);
        }

        return $response;
    }
522091
public function request(string $path, array $params = null, string $method = null, $body = null, array $headers = null):ResponseInterface{
		$method = $method ?? 'GET';
		$params = $this->requestParams($path, $params ?? [], $body ?? []);

		if($method === 'POST'){
			$body   = $params;
			$params = [];
		}

#		return parent::request('', $params, $method, $body, $headers);

		$request = $this->requestFactory
			->createRequest($method, Psr7\merge_query($this->apiURL, $params));

		foreach(array_merge($this->apiHeaders, $headers ?? []) as $header => $value){
			$request = $request->withAddedHeader($header, $value);
		}

		if($method === 'POST'){
			$request = $request->withHeader('Content-Type', 'application/x-www-form-urlencoded');
			$body    = $this->streamFactory->createStream(http_build_query($body, '', '&', PHP_QUERY_RFC1738));
			$request = $request->withBody($body);
		}

		return $this->http->sendRequest($request);
	}
38915
public function url($file = null, $extra = null, $rewrite = true) {
        if ($extra === false && $rewrite === true) {
            list($extra, $rewrite) = [null, $extra];
        }
        return url()->to($file, $extra, true, $rewrite);
    }
743369
public function create($file, $purpose, array $headers = [])
    {
        $response = $this->getClient()->request('POST', 'v1/files', [
            'headers'   => $headers,
            'multipart' => [
                [ 'name' => 'purpose', 'contents' => $purpose ],
                [ 'name' => 'file', 'contents' => fopen($file, 'r') ]
            ],
        ]);

        return json_decode($response->getBody(), true);
    }
461365
private function doMultipartUpload ($endpoint, $type, $stream, array $extra = [])
    {
        return json_decode(
            $this->client->send(
                new Request(
                    'POST',
                    Uri::withQueryValue(new Uri($endpoint), 'type', $type),
                    [],
                    new MultipartStream(array_merge([
                        [
                            'name'     => 'media',
                            'contents' => $stream,
                        ],
                    ], $extra))
                )
            )->getBody()
        );
    }
1209913
public function add_headers( $extra_headers ) {
		$ghu_extra_headers = [
			'RequiresWP'   => 'Requires WP',
			'RequiresPHP'  => 'Requires PHP',
			'ReleaseAsset' => 'Release Asset',
		];

		$uri_types = [
			'PluginURI' => ' Plugin URI',
			'ThemeURI'  => ' Theme URI',
		];

		foreach ( self::$git_servers as $server ) {
			foreach ( $uri_types as $uri_key => $uri_value ) {
				$ghu_extra_headers[ $server . $uri_key ] = $server . $uri_value;
			}
			foreach ( self::$extra_repo_headers as $header_key => $header_value ) {
				$ghu_extra_headers[ $server . $header_key ] = $server . ' ' . $header_value;
			}
		}

		self::$extra_headers = array_unique( array_merge( self::$extra_headers, $ghu_extra_headers ) );
		$extra_headers       = array_merge( (array) $extra_headers, $ghu_extra_headers );
		ksort( self::$extra_headers );

		return $extra_headers;
	}
457745
public function createdWithMeta(ResourceDocumentInterface $document, $object, array $additionalMeta = []): ResponseInterface
    {
        $response = $this->getMetaResponse($document, $object, 201, $additionalMeta);

        return $this->getResponseWithLocationHeader($document, $response);
    }
1366410
protected function httpPostRaw(string $path, $body, array $requestHeaders = []): ResponseInterface
    {
        try {
            $response = $this->httpClient->sendRequest(
                $this->requestBuilder->create('POST', $path, $requestHeaders, $body)
            );
        } catch (Psr18\NetworkExceptionInterface $e) {
            throw HttpServerException::networkError($e);
        }

        return $response;
    }