Ignore:
Timestamp:
2016-01-04T20:51:45+01:00 (11 years ago)
Author:
simon04
Message:

see #12292 - Allow to disconnect HttpClient in connecting phase

File:
1 edited

Legend:

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

    r9182 r9309  
    618618                url = new URL(new URL(getBaseUrl()), urlSuffix);
    619619                final HttpClient client = HttpClient.create(url, requestMethod).keepAlive(false);
     620                activeConnection = client;
    620621                if (fastFail) {
    621622                    client.setConnectTimeout(1000);
     
    640641                }
    641642
    642                 activeConnection = client.connect();
    643                 Main.info(activeConnection.getResponseMessage());
    644                 int retCode = activeConnection.getResponseCode();
     643                final HttpClient.Response response = client.connect();
     644                Main.info(response.getResponseMessage());
     645                int retCode = response.getResponseCode();
    645646
    646647                if (retCode >= 500) {
     
    652653                }
    653654
    654                 final String responseBody = activeConnection.fetchContent();
     655                final String responseBody = response.fetchContent();
    655656
    656657                String errorHeader = null;
    657658                // Look for a detailed error message from the server
    658                 if (activeConnection.getHeaderField("Error") != null) {
    659                     errorHeader = activeConnection.getHeaderField("Error");
     659                if (response.getHeaderField("Error") != null) {
     660                    errorHeader = response.getHeaderField("Error");
    660661                    Main.error("Error header: " + errorHeader);
    661662                } else if (retCode != HttpURLConnection.HTTP_OK && responseBody.length() > 0) {
Note: See TracChangeset for help on using the changeset viewer.