diff --git a/src/server/request-handler/request-handler.ts b/src/server/request-handler/request-handler.ts index f37a1e8..2984b89 100644 --- a/src/server/request-handler/request-handler.ts +++ b/src/server/request-handler/request-handler.ts @@ -3,7 +3,7 @@ import {Response} from "../i-response"; import {printRequest} from "../../util/request-util/request-util"; import {RequestHandlerOptions} from "./request-handler-options"; import {constants} from "http2"; -import {METHOD_NOT_ALLOWED, NOT_FOUND, OK} from "http-status-codes"; +import {METHOD_NOT_ALLOWED, OK} from "http-status-codes"; import {RegisteredControllers} from "../../controller/controller/registered-controllers"; import {IStaticController} from "../../controller/static/i-static-controller"; @@ -67,22 +67,10 @@ export class RequestHandler implements IRequestHandler { */ private async handleOptionsRequest (options: RequestHandlerOptions): Promise { - // Find the first matched controller - for (const controller of this.controllers) { - const match = controller.match(options.request); - if (match != null) { - return { - statusCode: options.request.http2 - ? constants.HTTP_STATUS_OK - : OK - }; - } - } - return { statusCode: options.request.http2 - ? constants.HTTP_STATUS_NOT_FOUND - : NOT_FOUND + ? constants.HTTP_STATUS_OK + : OK }; } } \ No newline at end of file diff --git a/test/server/server.test.ts b/test/server/server.test.ts index 5299832..a8d89f1 100644 --- a/test/server/server.test.ts +++ b/test/server/server.test.ts @@ -117,4 +117,20 @@ test("Will set a 'x-applied-polyfills' header on HTTP2 responses with a HTTP-fri }); t.true(result.polyfillsHeader != null); +}); + +test("Accepts OPTIONS requests. #1", async t => { + + const result = await sendRequest({ + http2: config.http2, + tls: true, + userAgent: ie("11"), + method: "OPTIONS", + host: config.host, + port: config.port, + path: `${constant.endpoint.polyfill}?features=event,custom-event,zone,es.promise.finally,pointer-event|force,systemjs|variant=system,intl|force|locale=en~da`, + acceptEncoding: undefined + }); + + t.true(result.statusCode === 200); }); \ No newline at end of file