Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

PrepareBodyMiddleware.php

Zuletzt modifiziert: 01.05.2026, 11:26 - Dateigröße: 3.15 KiB


 001  <?php
 002  namespace GuzzleHttp;
 003   
 004  use GuzzleHttp\Promise\PromiseInterface;
 005  use GuzzleHttp\Psr7;
 006  use Psr\Http\Message\RequestInterface;
 007   
 008  /**
 009   * Prepares requests that contain a body, adding the Content-Length,
 010   * Content-Type, and Expect headers.
 011   */
 012  class PrepareBodyMiddleware
 013  {
 014      /** @var callable  */
 015      private $nextHandler;
 016   
 017      /**
 018       * @param callable $nextHandler Next handler to invoke.
 019       */
 020      public function __construct(callable $nextHandler)
 021      {
 022          $this->nextHandler = $nextHandler;
 023      }
 024   
 025      /**
 026       * @param RequestInterface $request
 027       * @param array            $options
 028       *
 029       * @return PromiseInterface
 030       */
 031      public function __invoke(RequestInterface $request, array $options)
 032      {
 033          $fn = $this->nextHandler;
 034   
 035          // Don't do anything if the request has no body.
 036          if ($request->getBody()->getSize() === 0) {
 037              return $fn($request, $options);
 038          }
 039   
 040          $modify = [];
 041   
 042          // Add a default content-type if possible.
 043          if (!$request->hasHeader('Content-Type')) {
 044              if ($uri = $request->getBody()->getMetadata('uri')) {
 045                  if ($type = Psr7\mimetype_from_filename($uri)) {
 046                      $modify['set_headers']['Content-Type'] = $type;
 047                  }
 048              }
 049          }
 050   
 051          // Add a default content-length or transfer-encoding header.
 052          if (!$request->hasHeader('Content-Length')
 053              && !$request->hasHeader('Transfer-Encoding')
 054          ) {
 055              $size = $request->getBody()->getSize();
 056              if ($size !== null) {
 057                  $modify['set_headers']['Content-Length'] = $size;
 058              } else {
 059                  $modify['set_headers']['Transfer-Encoding'] = 'chunked';
 060              }
 061          }
 062   
 063          // Add the expect header if needed.
 064          $this->addExpectHeader($request, $options, $modify);
 065   
 066          return $fn(Psr7\modify_request($request, $modify), $options);
 067      }
 068   
 069      /**
 070       * Add expect header
 071       *
 072       * @return void
 073       */
 074      private function addExpectHeader(
 075          RequestInterface $request,
 076          array $options,
 077          array &$modify
 078      ) {
 079          // Determine if the Expect header should be used
 080          if ($request->hasHeader('Expect')) {
 081              return;
 082          }
 083   
 084          $expect = isset($options['expect']) ? $options['expect'] : null;
 085   
 086          // Return if disabled or if you're not using HTTP/1.1 or HTTP/2.0
 087          if ($expect === false || $request->getProtocolVersion() < 1.1) {
 088              return;
 089          }
 090   
 091          // The expect header is unconditionally enabled
 092          if ($expect === true) {
 093              $modify['set_headers']['Expect'] = '100-Continue';
 094              return;
 095          }
 096   
 097          // By default, send the expect header when the payload is > 1mb
 098          if ($expect === null) {
 099              $expect = 1048576;
 100          }
 101   
 102          // Always add if the body cannot be rewound, the size cannot be
 103          // determined, or the size is greater than the cutoff threshold
 104          $body = $request->getBody();
 105          $size = $body->getSize();
 106   
 107          if ($size === null || $size >= (int) $expect || !$body->isSeekable()) {
 108              $modify['set_headers']['Expect'] = '100-Continue';
 109          }
 110      }
 111  }
 112