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

Breadcrumb

  1. Drupal Core 11.1.x

ContentLength.php

Same filename in this branch
  1. 11.1.x core/lib/Drupal/Core/StackMiddleware/ContentLength.php

Namespace

Drupal\big_pipe\StackMiddleware

File

core/modules/big_pipe/src/StackMiddleware/ContentLength.php

View source
<?php

declare (strict_types=1);
namespace Drupal\big_pipe\StackMiddleware;

use Drupal\big_pipe\Render\BigPipeResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;

/**
 * Defines a big pipe middleware that removes Content-Length headers.
 */
final class ContentLength implements HttpKernelInterface {
    
    /**
     * Constructs a new ContentLength instance.
     *
     * @param \Symfony\Component\HttpKernel\HttpKernelInterface $httpKernel
     *   The wrapped HTTP kernel.
     */
    public function __construct(HttpKernelInterface $httpKernel) {
    }
    
    /**
     * {@inheritdoc}
     */
    public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE) : Response {
        $response = $this->httpKernel
            ->handle($request, $type, $catch);
        if (!$response instanceof BigPipeResponse) {
            return $response;
        }
        $response->headers
            ->remove('Content-Length');
        return $response;
    }

}

Classes

Title Deprecated Summary
ContentLength Defines a big pipe middleware that removes Content-Length headers.

API Navigation

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