Changeset 9182 in josm


Ignore:
Timestamp:
2015-12-27T22:01:58+01:00 (9 years ago)
Author:
simon04
Message:

see #12231 - No read timeout for OsmApi connections

Fixes regression from r9172

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r9172 r9182  
    619619                final HttpClient client = HttpClient.create(url, requestMethod).keepAlive(false);
    620620                if (fastFail) {
     621                    client.setConnectTimeout(1000);
    621622                    client.setReadTimeout(1000);
     623                } else {
     624                    // use default connect timeout from org.openstreetmap.josm.tools.HttpClient.connectTimeout
     625                    client.setReadTimeout(0);
    622626                }
    623627                if (doAuthenticate) {
     
    626630
    627631                if ("PUT".equals(requestMethod) || "POST".equals(requestMethod) || "DELETE".equals(requestMethod)) {
     632                    client.setHeader("Content-Type", "text/xml");
    628633                    // It seems that certain bits of the Ruby API are very unhappy upon
    629634                    // receipt of a PUT/POST message without a Content-length header,
     
    632637                    // we use the output stream, we create an output stream for PUT/POST
    633638                    // even if there is no payload.
    634                     client.setRequestBody(requestBody.getBytes(StandardCharsets.UTF_8));
     639                    client.setRequestBody((requestBody != null ? requestBody : "").getBytes(StandardCharsets.UTF_8));
    635640                }
    636641
  • trunk/src/org/openstreetmap/josm/tools/HttpClient.java

    r9179 r9182  
    9292
    9393        if ("PUT".equals(requestMethod) || "POST".equals(requestMethod) || "DELETE".equals(requestMethod)) {
     94            Main.info("{0} {1} ({2} kB) ...", requestMethod, url, requestBody.length / 1024);
    9495            headers.put("Content-Length", String.valueOf(requestBody.length));
    9596            connection.setDoOutput(true);
     
    112113                }
    113114            } catch (IOException e) {
     115                Main.warn(e);
    114116                //noinspection ThrowableResultOfMethodCallIgnored
    115117                Main.addNetworkError(url, Utils.getRootCause(e));
Note: See TracChangeset for help on using the changeset viewer.