Revert "Add FixAcceptHeader middleware"
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 13 Apr 2023 14:03:08 +0000 (16:03 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 14 Apr 2023 11:54:49 +0000 (13:54 +0200)
This does not appear to be generally useful. The JavaScript was modified to
send appropriate headers now.

This reverts commit fcdb3da3976359f8077c2f3a5ef2af5ebdd2d89c.

wcfsetup/install/files/lib/http/middleware/FixAcceptHeader.class.php [deleted file]
wcfsetup/install/files/lib/system/request/RequestHandler.class.php

diff --git a/wcfsetup/install/files/lib/http/middleware/FixAcceptHeader.class.php b/wcfsetup/install/files/lib/http/middleware/FixAcceptHeader.class.php
deleted file mode 100644 (file)
index 9fecb6e..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-namespace wcf\http\middleware;
-
-use Psr\Http\Message\ResponseInterface;
-use Psr\Http\Message\ServerRequestInterface;
-use Psr\Http\Server\MiddlewareInterface;
-use Psr\Http\Server\RequestHandlerInterface;
-use wcf\http\Helper;
-
-/**
- * Adds a preference for application/json responses for AJAX requests that accept everything.
- *
- * @author  Tim Duesterhus
- * @copyright   2001-2022 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @since   6.0
- */
-final class FixAcceptHeader implements MiddlewareInterface
-{
-    /**
-     * @inheritDoc
-     */
-    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
-    {
-        if (Helper::isAjaxRequest($request)) {
-            if (!$request->hasHeader('accept') || $request->getHeaderLine('accept') === '*/*') {
-                $request = $request->withHeader('accept', 'application/json, */*; q=0.9');
-            }
-        }
-
-        return $handler->handle($request);
-    }
-}
index 34833bbb8df5a8d227f80ce3f489aedbb87ad541..4fb3115fad9101e2a534d65023d9822369d9d24a 100644 (file)
@@ -22,7 +22,6 @@ use wcf\http\middleware\EnforceAcpAuthentication;
 use wcf\http\middleware\EnforceCacheControlPrivate;
 use wcf\http\middleware\EnforceFrameOptions;
 use wcf\http\middleware\EnforceNoCacheForTemporaryRedirects;
-use wcf\http\middleware\FixAcceptHeader;
 use wcf\http\middleware\HandleExceptions;
 use wcf\http\middleware\HandleStartupErrors;
 use wcf\http\middleware\HandleValinorMappingErrors;
@@ -118,7 +117,6 @@ final class RequestHandler extends SingletonFactory
 
                 $pipeline = new Pipeline([
                     new HandleStartupErrors(),
-                    new FixAcceptHeader(),
                     new PreventMimeSniffing(),
                     new AddAcpSecurityHeaders(),
                     new EnforceCacheControlPrivate(),