Changeset 9314 in josm for trunk/src/org


Ignore:
Timestamp:
2016-01-04T23:55:48+01:00 (4 years ago)
Author:
simon04
Message:

fix #7094 see #12231 - HttpClient: set Content-Length for all POST/PUT/DELETE requests

File:
1 edited

Legend:

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

    r9309 r9314  
    4242    private byte[] requestBody;
    4343    private long ifModifiedSince;
    44     private long contentLength;
    4544    private final Map<String, String> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    4645    private int maxRedirects = Main.pref.getInteger("socket.maxredirects", 5);
     
    8685            connection.setIfModifiedSince(ifModifiedSince);
    8786        }
    88         if (contentLength > 0) {
    89             connection.setFixedLengthStreamingMode(contentLength);
    90         }
    9187        connection.setUseCaches(useCache);
    9288        if (!useCache) {
     
    104100        if ("PUT".equals(requestMethod) || "POST".equals(requestMethod) || "DELETE".equals(requestMethod)) {
    105101            Main.info("{0} {1} ({2}) ...", requestMethod, url, Utils.getSizeString(requestBody.length, Locale.getDefault()));
    106             headers.put("Content-Length", String.valueOf(requestBody.length));
     102            connection.setFixedLengthStreamingMode(requestBody.length);
    107103            connection.setDoOutput(true);
    108104            try (OutputStream out = new BufferedOutputStream(
     
    517513     * @see HttpURLConnection#setFixedLengthStreamingMode(long)
    518514     * @since 9178
    519      */
     515     * @deprecated Submitting data via POST, PUT, DELETE automatically sets this property on the connection
     516     */
     517    @Deprecated
    520518    public HttpClient setFixedLengthStreamingMode(long contentLength) {
    521         this.contentLength = contentLength;
    522519        return this;
    523520    }
Note: See TracChangeset for help on using the changeset viewer.