Changeset 9309 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2016-01-04T20:51:45+01:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r9182 r9309 618 618 url = new URL(new URL(getBaseUrl()), urlSuffix); 619 619 final HttpClient client = HttpClient.create(url, requestMethod).keepAlive(false); 620 activeConnection = client; 620 621 if (fastFail) { 621 622 client.setConnectTimeout(1000); … … 640 641 } 641 642 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(); 645 646 646 647 if (retCode >= 500) { … … 652 653 } 653 654 654 final String responseBody = activeConnection.fetchContent();655 final String responseBody = response.fetchContent(); 655 656 656 657 String errorHeader = null; 657 658 // 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"); 660 661 Main.error("Error header: " + errorHeader); 661 662 } else if (retCode != HttpURLConnection.HTTP_OK && responseBody.length() > 0) { -
trunk/src/org/openstreetmap/josm/io/OsmConnection.java
r9172 r9309 31 31 public class OsmConnection { 32 32 protected boolean cancel; 33 protected HttpClient .ResponseactiveConnection;33 protected HttpClient activeConnection; 34 34 protected OAuthParameters oauthParameters; 35 35 -
trunk/src/org/openstreetmap/josm/io/OsmServerReader.java
r9308 r9309 123 123 124 124 final HttpClient client = HttpClient.create(url); 125 activeConnection = client; 125 126 client.setReasonForRequest(reason); 126 127 adaptRequest(client); … … 131 132 throw new OsmTransferCanceledException("Operation canceled"); 132 133 134 final HttpClient.Response response; 133 135 try { 134 activeConnection= client.connect(progressMonitor);136 response = client.connect(progressMonitor); 135 137 } catch (Exception e) { 136 138 Main.error(e); … … 141 143 } 142 144 try { 143 if ( activeConnection.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED)145 if (response.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) 144 146 throw new OsmApiException(HttpURLConnection.HTTP_UNAUTHORIZED, null, null); 145 147 146 if ( activeConnection.getResponseCode() == HttpURLConnection.HTTP_PROXY_AUTH)148 if (response.getResponseCode() == HttpURLConnection.HTTP_PROXY_AUTH) 147 149 throw new OsmTransferCanceledException("Proxy Authentication Required"); 148 150 149 if ( activeConnection.getResponseCode() != HttpURLConnection.HTTP_OK) {150 String errorHeader = activeConnection.getHeaderField("Error");151 if (response.getResponseCode() != HttpURLConnection.HTTP_OK) { 152 String errorHeader = response.getHeaderField("Error"); 151 153 String errorBody; 152 154 try { 153 errorBody = activeConnection.fetchContent();155 errorBody = response.fetchContent(); 154 156 } catch (Exception e) { 155 157 errorBody = tr("Reading error text failed."); 156 158 } 157 throw new OsmApiException( activeConnection.getResponseCode(), errorHeader, errorBody, url.toString());159 throw new OsmApiException(response.getResponseCode(), errorHeader, errorBody, url.toString()); 158 160 } 159 161 160 activeConnection.uncompressAccordingToContentDisposition(uncompressAccordingToContentDisposition);161 return activeConnection.getContent();162 response.uncompressAccordingToContentDisposition(uncompressAccordingToContentDisposition); 163 return response.getContent(); 162 164 } catch (OsmTransferException e) { 163 165 throw e;
Note: See TracChangeset
for help on using the changeset viewer.