Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CurlFactory.php

function CurlFactory::applyMethod

1 call to CurlFactory::applyMethod()
CurlFactory::create in vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php
Creates a cURL handle resource.

File

vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php, line 330

Class

CurlFactory
Creates curl resources from a request

Namespace

GuzzleHttp\Handler

Code

private function applyMethod(EasyHandle $easy, array &$conf) : void {
    $body = $easy->request
        ->getBody();
    $size = $body->getSize();
    if ($size === null || $size > 0) {
        $this->applyBody($easy->request, $easy->options, $conf);
        return;
    }
    $method = $easy->request
        ->getMethod();
    if ($method === 'PUT' || $method === 'POST') {
        // See https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.2
        if (!$easy->request
            ->hasHeader('Content-Length')) {
            $conf[\CURLOPT_HTTPHEADER][] = 'Content-Length: 0';
        }
    }
    elseif ($method === 'HEAD') {
        $conf[\CURLOPT_NOBODY] = true;
        unset($conf[\CURLOPT_WRITEFUNCTION], $conf[\CURLOPT_READFUNCTION], $conf[\CURLOPT_FILE], $conf[\CURLOPT_INFILE]);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal