src/java.net.http/share/classes/jdk/internal/net/http/RedirectFilter.java
changeset 50681 4254bed3c09d
parent 49765 ee6f7a61f3a5
child 56795 03ece2518428
child 58758 2b13d126a2d8
--- a/src/java.net.http/share/classes/jdk/internal/net/http/RedirectFilter.java	Wed Jun 20 17:15:16 2018 +0200
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/RedirectFilter.java	Wed Jun 20 09:05:57 2018 -0700
@@ -43,6 +43,13 @@
     static final int DEFAULT_MAX_REDIRECTS = 5;
     URI uri;
 
+    /*
+     * NOT_MODIFIED status code results from a conditional GET where
+     * the server does not (must not) return a response body because
+     * the condition specified in the request disallows it
+     */
+    static final int HTTP_NOT_MODIFIED = 304;
+
     static final int max_redirects = Utils.getIntegerNetProperty(
             "jdk.httpclient.redirects.retrylimit", DEFAULT_MAX_REDIRECTS
     );
@@ -91,6 +98,10 @@
         if (rcode == 200 || policy == HttpClient.Redirect.NEVER) {
             return null;
         }
+
+        if (rcode == HTTP_NOT_MODIFIED)
+            return null;
+
         if (rcode >= 300 && rcode <= 399) {
             URI redir = getRedirectedURI(r.headers());
             String newMethod = redirectedMethod(rcode, method);