Class RequestValidateTrace

  • All Implemented Interfaces:
    org.apache.hc.core5.http.HttpRequestInterceptor

    @Contract(threading=STATELESS)
    public class RequestValidateTrace
    extends java.lang.Object
    implements org.apache.hc.core5.http.HttpRequestInterceptor
    RequestTraceInterceptor

    This class serves as an interceptor for HTTP TRACE requests, ensuring they adhere to specific security and protocol guidelines.

    Responsibilities:

    • Validates TRACE requests by checking for sensitive headers such as Authorization and Cookie.
    • Ensures that TRACE requests do not contain a request body, throwing a ProtocolException if a body is present.

    Thread Safety: This class is stateless and therefore thread-safe, as indicated by its ThreadingBehavior.STATELESS annotation.

    Interceptor Behavior:

    • If the HTTP method is TRACE, the interceptor throws a ProtocolException if any Authorization or Cookie headers are present to prevent sensitive data leakage.
    • If a TRACE request contains a body, a ProtocolException is thrown.
    Version:
    5.4
    See Also:
    HttpRequestInterceptor, HttpException, IOException, ProtocolException, Method.TRACE, HttpHeaders.AUTHORIZATION, HttpHeaders.COOKIE
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static org.apache.hc.core5.http.HttpRequestInterceptor INSTANCE
      Default instance of RequestValidateTrace.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void process​(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.EntityDetails entity, org.apache.hc.core5.http.protocol.HttpContext context)
      Processes an incoming HTTP request.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INSTANCE

        public static final org.apache.hc.core5.http.HttpRequestInterceptor INSTANCE
        Default instance of RequestValidateTrace.
    • Constructor Detail

      • RequestValidateTrace

        public RequestValidateTrace()
        Default constructor.
    • Method Detail

      • process

        public void process​(org.apache.hc.core5.http.HttpRequest request,
                            org.apache.hc.core5.http.EntityDetails entity,
                            org.apache.hc.core5.http.protocol.HttpContext context)
                     throws org.apache.hc.core5.http.HttpException,
                            java.io.IOException
        Processes an incoming HTTP request. If the request is of type TRACE, it performs the following actions:
        • Throws a ProtocolException if the request contains an Authorization header to prevent sensitive data leakage.
        • Throws a ProtocolException if the request contains a Cookie header to prevent sensitive data leakage.
        • Throws a ProtocolException if the request contains a body.
        Specified by:
        process in interface org.apache.hc.core5.http.HttpRequestInterceptor
        Parameters:
        request - The incoming HTTP request. Cannot be null.
        entity - Details of the request entity. Can be null.
        context - The HTTP context.
        Throws:
        org.apache.hc.core5.http.HttpException - If a protocol error occurs.
        java.io.IOException - If an I/O error occurs.