Index: trunk/src/org/openstreetmap/josm/io/ProgressOutputStream.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/ProgressOutputStream.java	(revision 10301)
+++ trunk/src/org/openstreetmap/josm/io/ProgressOutputStream.java	(revision 10302)
@@ -19,4 +19,5 @@
     private final StreamProgressUpdater updater;
     private final OutputStream out;
+    private final boolean finishOnClose;
 
     /**
@@ -26,11 +27,12 @@
      * @param size the total size which will be sent
      * @param progressMonitor the monitor to report to
+     * @param finishOnClose whether to call {@link ProgressMonitor#finishTask} when this stream is closed
+     * @since 10302
      */
-    public ProgressOutputStream(OutputStream out, long size, ProgressMonitor progressMonitor) {
-        if (progressMonitor == null) {
-            progressMonitor = NullProgressMonitor.INSTANCE;
-        }
-        this.updater = new StreamProgressUpdater(size, progressMonitor, tr("Uploading data ..."));
+    public ProgressOutputStream(OutputStream out, long size, ProgressMonitor progressMonitor, boolean finishOnClose) {
+        this.updater = new StreamProgressUpdater(size,
+                progressMonitor != null ? progressMonitor : NullProgressMonitor.INSTANCE, tr("Uploading data ..."));
         this.out = out;
+        this.finishOnClose = finishOnClose;
     }
 
@@ -52,5 +54,7 @@
             out.close();
         } finally {
-            updater.finishTask();
+            if (finishOnClose) {
+                updater.finishTask();
+            }
         }
     }
Index: trunk/src/org/openstreetmap/josm/tools/HttpClient.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 10301)
+++ trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 10302)
@@ -52,4 +52,5 @@
     private HttpURLConnection connection; // to allow disconnecting before `response` is set
     private Response response;
+    private boolean finishOnCloseOutput = true;
 
     static {
@@ -111,5 +112,5 @@
             connection.setDoOutput(true);
             try (OutputStream out = new BufferedOutputStream(
-                    new ProgressOutputStream(connection.getOutputStream(), requestBody.length, progressMonitor))) {
+                    new ProgressOutputStream(connection.getOutputStream(), requestBody.length, progressMonitor, finishOnCloseOutput))) {
                 out.write(requestBody);
             }
@@ -598,4 +599,15 @@
     }
 
+    /**
+     * Sets whether the progress monitor task will be finished when the output stream is closed. This is {@code true} by default.
+     * @param finishOnCloseOutput whether the progress monitor task will be finished when the output stream is closed
+     * @return {@code this}
+     * @since 10302
+     */
+    public HttpClient setFinishOnCloseOutput(boolean finishOnCloseOutput) {
+        this.finishOnCloseOutput = finishOnCloseOutput;
+        return this;
+    }
+
     private static boolean isRedirect(final int statusCode) {
         switch (statusCode) {
Index: trunk/test/functional/org/openstreetmap/josm/tools/HttpClientTest.java
===================================================================
--- trunk/test/functional/org/openstreetmap/josm/tools/HttpClientTest.java	(revision 10301)
+++ trunk/test/functional/org/openstreetmap/josm/tools/HttpClientTest.java	(revision 10302)
@@ -101,4 +101,5 @@
                 .setHeader("Content-Type", "text/plain")
                 .setRequestBody(text.getBytes(StandardCharsets.UTF_8))
+                .setFinishOnCloseOutput(false) // to fix #12583, not sure if it's the best way to do it
                 .connect(progress);
         assertThat(response.getResponseCode(), is(200));
@@ -114,4 +115,5 @@
                 .setHeader("Content-Type", "text/plain")
                 .setRequestBody("".getBytes(StandardCharsets.UTF_8))
+                .setFinishOnCloseOutput(false) // to fix #12583, not sure if it's the best way to do it
                 .connect(progress);
         assertThat(response.getResponseCode(), is(200));
