Changeset 15741 in josm


Ignore:
Timestamp:
2020-01-20T23:18:40+01:00 (5 years ago)
Author:
simon04
Message:

HttpClient: use cache by default

This is in accordance with java.net.URLConnection#getDefaultUseCaches(java.lang.String)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/HttpClient.java

    r15423 r15741  
    6464    private final Map<String, String> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    6565    private int maxRedirects = Config.getPref().getInt("socket.maxredirects", 5);
    66     private boolean useCache;
     66    private boolean useCache = true;
    6767    private String reasonForRequest;
    6868    private String outputMessage = tr("Uploading data ...");
     
    614614
    615615    /**
    616      * Determines whether not to set header {@code Cache-Control=no-cache}
     616     * Determines whether not to set header {@code Cache-Control=no-cache}.
     617     * By default, {@code useCache} is true, i.e., the header {@code Cache-Control=no-cache} is not sent.
     618     *
    617619     * @return whether not to set header {@code Cache-Control=no-cache}
    618620     * @since 15229
     
    657659
    658660    /**
    659      * Sets whether not to set header {@code Cache-Control=no-cache}
     661     * Sets whether not to set header {@code Cache-Control=no-cache}.
     662     * By default, {@code useCache} is true, i.e., the header {@code Cache-Control=no-cache} is not sent.
    660663     *
    661664     * @param useCache whether not to set header {@code Cache-Control=no-cache}
  • trunk/test/functional/org/openstreetmap/josm/tools/HttpClientTest.java

    r14191 r15741  
    117117            assertThat(root.getJsonObject("args").getString("foo"), is("bar"));
    118118            assertThat(root.getString("url"), is("https://httpbin.org/get?foo=bar"));
     119            assertThat(root.getJsonObject("headers").get("Cache-Control"), nullValue());
     120            assertThat(root.getJsonObject("headers").get("Pragma"), nullValue());
    119121        }
    120122    }
Note: See TracChangeset for help on using the changeset viewer.