arturobernalg commented on code in PR #500:
URL: 
https://github.com/apache/httpcomponents-core/pull/500#discussion_r1811122466


##########
httpcore5/src/main/java/org/apache/hc/core5/http/protocol/ResponseDate.java:
##########
@@ -46,27 +46,49 @@
  * This interceptor is recommended for the HTTP protocol conformance and
  * the correct operation of the server-side message processing pipeline.
  * </p>
+ * <p>
+ * If the {@code Date} header is invalid, the interceptor will replace it with 
the
+ * time at which the response was received.
+ * </p>
  *
  * @since 4.0
  */
 @Contract(threading = ThreadingBehavior.SAFE)
 public class ResponseDate implements HttpResponseInterceptor {
 
+    /**
+     * Indicates whether to replace an invalid Date header.
+     *
+     * @since 5.4
+     */
+    private final boolean replaceInvalidDate;
+
     public static final ResponseDate INSTANCE = new ResponseDate();
 
     public ResponseDate() {
+        this(false);
+    }
+
+    /**
+     * Constructs a ResponseDate interceptor.
+     *
+     * @param replaceInvalidDate Whether to replace an invalid {@code Date} 
header.
+     *                           If {@code true}, the interceptor will replace 
any
+     *                           detected invalid {@code Date} header with a 
valid value.
+     * @since 5.4
+     */
+    public ResponseDate(final boolean replaceInvalidDate) {
         super();
+        this.replaceInvalidDate = replaceInvalidDate;
     }
 
     @Override
     public void process(final HttpResponse response, final EntityDetails 
entity, final HttpContext context)
             throws HttpException, IOException {
         Args.notNull(response, "HTTP response");
-        final int status = response.getCode();
-        if (status >= HttpStatus.SC_OK &&
-            !response.containsHeader(HttpHeaders.DATE)) {
+        final Header dateHeader = response.getFirstHeader(HttpHeaders.DATE);

Review Comment:
   @ok2c changed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to