Index: /trunk/src/org/openstreetmap/josm/tools/HttpClient.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 9177)
+++ /trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 9178)
@@ -9,4 +9,5 @@
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.HttpRetryException;
 import java.net.HttpURLConnection;
 import java.net.URL;
@@ -36,4 +37,5 @@
     private byte[] requestBody;
     private long ifModifiedSince;
+    private long contentLength;
     private final Map<String, String> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
     private int maxRedirects = Main.pref.getInteger("socket.maxredirects", 5);
@@ -61,4 +63,7 @@
         if (ifModifiedSince > 0) {
             connection.setIfModifiedSince(ifModifiedSince);
+        }
+        if (contentLength > 0) {
+            connection.setFixedLengthStreamingMode(contentLength);
         }
         connection.setUseCaches(useCache);
@@ -158,4 +163,5 @@
          * {@code Content-Disposition}
          * @return {@code this}
+         * @since 9172
          */
         public Response uncompressAccordingToContentDisposition(boolean uncompressAccordingToContentDisposition) {
@@ -168,4 +174,5 @@
          * @return the URL
          * @see HttpURLConnection#getURL()
+         * @since 9172
          */
         public URL getURL() {
@@ -177,4 +184,5 @@
          * @return the HTTP request method
          * @see HttpURLConnection#getRequestMethod()
+         * @since 9172
          */
         public String getRequestMethod() {
@@ -260,4 +268,5 @@
          *
          * @see HttpURLConnection#getResponseMessage()
+         * @since 9172
          */
         public String getResponseMessage() {
@@ -294,4 +303,5 @@
          * @return the value of the named header field, or {@code null} if there is no such field in the header
          * @see HttpURLConnection#getHeaderField(String)
+         * @since 9172
          */
         public String getHeaderField(String name) {
@@ -304,4 +314,5 @@
          * @return unmodifiable List of Strings that represents the corresponding field values
          * @see HttpURLConnection#getHeaderFields()
+         * @since 9172
          */
         public List<String> getHeaderFields(String name) {
@@ -353,4 +364,5 @@
      * @see #create(URL)
      * @see #create(URL, String)
+     * @since 9172
      */
     public URL getURL() {
@@ -362,4 +374,5 @@
      * @return the HTTP request method
      * @see #create(URL, String)
+     * @since 9172
      */
     public String getRequestMethod() {
@@ -371,4 +384,5 @@
      * @param header HTTP header name
      * @return HTTP header value
+     * @since 9172
      */
     public String getRequestHeader(String header) {
@@ -420,8 +434,29 @@
      * @param readTimeout an {@code int} that specifies the read timeout value in milliseconds
      * @return {@code this}
-     * @see HttpURLConnection#setReadTimeout(int) (int)
+     * @see HttpURLConnection#setReadTimeout(int)
      */
     public HttpClient setReadTimeout(int readTimeout) {
         this.readTimeout = readTimeout;
+        return this;
+    }
+
+    /**
+     * This method is used to enable streaming of a HTTP request body without internal buffering,
+     * when the content length is known in advance.
+     * <p>
+     * An exception will be thrown if the application attempts to write more data than the indicated content-length,
+     * or if the application closes the OutputStream before writing the indicated amount.
+     * <p>
+     * When output streaming is enabled, authentication and redirection cannot be handled automatically.
+     * A {@linkplain HttpRetryException} will be thrown when reading the response if authentication or redirection
+     * are required. This exception can be queried for the details of the error.
+     *
+     * @param contentLength The number of bytes which will be written to the OutputStream
+     * @return {@code this}
+     * @see HttpURLConnection#setFixedLengthStreamingMode(long)
+     * @since 9178
+     */
+    public HttpClient setFixedLengthStreamingMode(long contentLength) {
+        this.contentLength = contentLength;
         return this;
     }
@@ -500,4 +535,5 @@
      * @param reasonForRequest Reason to show
      * @return {@code this}
+     * @since 9172
      */
     public HttpClient setReasonForRequest(String reasonForRequest) {
