Ignore:
Timestamp:
2016-05-30T09:24:08+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #12583 - fix unit tests by adding a new mode to HttpClient. Don't know if it's the best way to do it...

File:
1 edited

Legend:

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

    r10300 r10302  
    5252    private HttpURLConnection connection; // to allow disconnecting before `response` is set
    5353    private Response response;
     54    private boolean finishOnCloseOutput = true;
    5455
    5556    static {
     
    111112            connection.setDoOutput(true);
    112113            try (OutputStream out = new BufferedOutputStream(
    113                     new ProgressOutputStream(connection.getOutputStream(), requestBody.length, progressMonitor))) {
     114                    new ProgressOutputStream(connection.getOutputStream(), requestBody.length, progressMonitor, finishOnCloseOutput))) {
    114115                out.write(requestBody);
    115116            }
     
    598599    }
    599600
     601    /**
     602     * Sets whether the progress monitor task will be finished when the output stream is closed. This is {@code true} by default.
     603     * @param finishOnCloseOutput whether the progress monitor task will be finished when the output stream is closed
     604     * @return {@code this}
     605     * @since 10302
     606     */
     607    public HttpClient setFinishOnCloseOutput(boolean finishOnCloseOutput) {
     608        this.finishOnCloseOutput = finishOnCloseOutput;
     609        return this;
     610    }
     611
    600612    private static boolean isRedirect(final int statusCode) {
    601613        switch (statusCode) {
Note: See TracChangeset for help on using the changeset viewer.