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 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
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.STATELESS annotation.
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.apache.hc.core5.http.HttpRequestInterceptorDefault instance ofRequestValidateTrace. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprocess(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 Details
-
INSTANCE
public static final org.apache.hc.core5.http.HttpRequestInterceptor INSTANCEDefault instance ofRequestValidateTrace.
-
-
Constructor Details
-
RequestValidateTrace
public RequestValidateTrace()Default constructor.
-
-
Method Details
-
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, IOException Processes 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.IOException- If an I/O error occurs.
- Throws a
-