001/*
002 * Copyright 2022-2026 Revetware LLC.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package com.soklet;
018
019/**
020 * Reasons an HTTP transport can reject incoming bytes before it has enough
021 * valid information to construct a {@link Request}.
022 * <p>
023 * These values describe why request construction stopped; they do not prescribe an
024 * HTTP response status. A {@link ResponseMarshaler} may choose any final status
025 * from {@code 200} through {@code 599} for an unparsed-request response.
026 *
027 * <p>
028 * This type may gain reviewed constants in Soklet 4.x; use a forward-compatible default when switching over its values.
029 *
030 * @author <a href="https://www.revetkn.com">Mark Allen</a>
031 */
032public enum UnparsedRequestReason {
033        /**
034         * The incoming bytes do not form a valid HTTP request.
035         * The default response marshaler conventionally uses HTTP 400.
036         */
037        MALFORMED_REQUEST,
038        /**
039         * The request target exceeds the transport's configured limit.
040         * The default response marshaler conventionally uses HTTP 414.
041         */
042        REQUEST_TARGET_TOO_LONG,
043        /**
044         * The request declares an expectation the transport cannot satisfy.
045         * The default response marshaler conventionally uses HTTP 417.
046         */
047        EXPECTATION_FAILED,
048        /**
049         * The request header section exceeds a configured transport limit.
050         * The default response marshaler conventionally uses HTTP 431.
051         */
052        REQUEST_HEADERS_TOO_LARGE,
053        /**
054         * Reading an in-progress request exceeded the transport's deadline.
055         * The default response marshaler conventionally uses HTTP 408.
056         */
057        REQUEST_READ_TIMEOUT,
058        /**
059         * The aggregate request size exceeds a configured limit before
060         * a valid {@link Request} can be constructed. The default marshaler uses HTTP 413.
061         */
062        REQUEST_TOO_LARGE,
063        /**
064         * Opt-in request decompression does not support the declared content coding.
065         * The default response marshaler conventionally uses HTTP 415.
066         */
067        UNSUPPORTED_CONTENT_ENCODING,
068        /**
069         * The request body cannot be decoded using its declared content coding.
070         * The default response marshaler conventionally uses HTTP 400.
071         */
072        REQUEST_BODY_DECOMPRESSION_FAILED
073}