Class RequestValidateTrace
- java.lang.Object
-
- org.apache.hc.client5.http.protocol.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.HttpRequestInterceptorRequestTraceInterceptorThis 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
AuthorizationandCookie. - Ensures that TRACE requests do not contain a request body, throwing a
ProtocolExceptionif a body is present.
Thread Safety: This class is stateless and therefore thread-safe, as indicated by its
ThreadingBehavior.STATELESSannotation.Interceptor Behavior:
- If the HTTP method is TRACE, the interceptor throws a
ProtocolExceptionif anyAuthorizationorCookieheaders are present to prevent sensitive data leakage. - If a TRACE request contains a body, a
ProtocolExceptionis 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.HttpRequestInterceptorINSTANCEDefault instance ofRequestValidateTrace.
-
Constructor Summary
Constructors Constructor Description RequestValidateTrace()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidprocess(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.
-
-
-
Field Detail
-
INSTANCE
public static final org.apache.hc.core5.http.HttpRequestInterceptor INSTANCE
Default instance ofRequestValidateTrace.
-
-
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.IOExceptionProcesses an incoming HTTP request. If the request is of type TRACE, it performs the following actions:- Throws a
ProtocolExceptionif the request contains anAuthorizationheader to prevent sensitive data leakage. - Throws a
ProtocolExceptionif the request contains aCookieheader to prevent sensitive data leakage. - Throws a
ProtocolExceptionif the request contains a body.
- Specified by:
processin interfaceorg.apache.hc.core5.http.HttpRequestInterceptor- Parameters:
request- The incoming HTTP request. Cannot benull.entity- Details of the request entity. Can benull.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.
- Throws a
-
-