Changeset 9309 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2016-01-04T20:51:45+01:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java
r9171 r9309 325 325 326 326 private final String searchExpression; 327 private HttpClient .Responseconnection;327 private HttpClient connection; 328 328 private List<SearchResult> data; 329 329 private boolean canceled; … … 368 368 URL url = new URL(urlString); 369 369 synchronized (this) { 370 connection = HttpClient.create(url).connect(); 371 } 372 try (Reader reader = connection.getContentReader()) { 370 connection = HttpClient.create(url); 371 connection.connect(); 372 } 373 try (Reader reader = connection.getResponse().getContentReader()) { 373 374 InputSource inputSource = new InputSource(reader); 374 375 NameFinderResultParser parser = new NameFinderResultParser(); -
trunk/src/org/openstreetmap/josm/gui/io/DownloadFileTask.java
r9296 r9309 69 69 70 70 private boolean canceled; 71 private HttpClient .ResponsedownloadConnection;71 private HttpClient downloadConnection; 72 72 73 73 private synchronized void closeConnectionIfNeeded() { … … 103 103 long size; 104 104 synchronized (this) { 105 downloadConnection = HttpClient.create(url).useCache(false).connect(); 106 size = downloadConnection.getContentLength(); 105 downloadConnection = HttpClient.create(url).useCache(false); 106 downloadConnection.connect(); 107 size = downloadConnection.getResponse().getContentLength(); 107 108 } 108 109 … … 111 112 112 113 try ( 113 InputStream in = downloadConnection.get Content();114 InputStream in = downloadConnection.getResponse().getContent(); 114 115 OutputStream out = new FileOutputStream(file) 115 116 ) { -
trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java
r9301 r9309 44 44 private final OAuthProvider provider; 45 45 private boolean canceled; 46 private HttpClient .Responseconnection;46 private HttpClient connection; 47 47 48 48 private static class SessionId { … … 183 183 184 184 protected String extractToken() { 185 try (BufferedReader r = connection.get ContentReader()) {185 try (BufferedReader r = connection.getResponse().getContentReader()) { 186 186 String c; 187 187 Pattern p = Pattern.compile(".*authenticity_token.*value=\"([^\"]+)\".*"); … … 200 200 201 201 protected SessionId extractOsmSession() { 202 List<String> setCookies = connection.get HeaderFields().get("Set-Cookie");202 List<String> setCookies = connection.getResponse().getHeaderFields().get("Set-Cookie"); 203 203 if (setCookies == null) 204 204 // no cookies set … … 293 293 URL url = new URL(sb.toString()); 294 294 synchronized (this) { 295 connection = HttpClient.create(url).connect(); 295 connection = HttpClient.create(url); 296 connection.connect(); 296 297 } 297 298 SessionId sessionId = extractOsmSession(); … … 322 323 synchronized (this) { 323 324 connection = HttpClient.create(url) 324 .setHeader("Cookie", "_osm_session=" + sessionId.id + "; _osm_username=" + sessionId.userName) 325 325 .setHeader("Cookie", "_osm_session=" + sessionId.id + "; _osm_username=" + sessionId.userName); 326 connection.connect(); 326 327 } 327 328 sessionId.token = extractToken(); … … 357 358 358 359 synchronized (this) { 359 connection = client.connect(); 360 connection = client; 361 connection.connect(); 360 362 } 361 363 … … 364 366 // an error page is sent to back to the user. 365 367 // 366 int retCode = connection.getResponse Code();368 int retCode = connection.getResponse().getResponseCode(); 367 369 if (retCode != HttpURLConnection.HTTP_MOVED_TEMP) 368 370 throw new OsmOAuthAuthorizationException(tr("Failed to authenticate user ''{0}'' with password ''***'' as OAuth user", … … 383 385 URL url = new URL(buildOsmLogoutUrl()); 384 386 synchronized (this) { 385 connection = HttpClient.create(url).setMaxRedirects(-1).connect(); 387 connection = HttpClient.create(url).setMaxRedirects(-1); 388 connection.connect(); 386 389 } 387 390 } catch (IOException e) { … … 432 435 433 436 synchronized (this) { 434 connection = client.connect(); 435 } 436 437 int retCode = connection.getResponseCode(); 437 connection = client; 438 connection.connect(); 439 } 440 441 int retCode = connection.getResponse().getResponseCode(); 438 442 if (retCode != HttpURLConnection.HTTP_OK) 439 443 throw new OsmOAuthAuthorizationException(tr("Failed to authorize OAuth request ''{0}''", requestToken.getKey())); -
trunk/src/org/openstreetmap/josm/gui/oauth/TestAccessTokenTask.java
r9172 r9309 46 46 private final Component parent; 47 47 private final String apiUrl; 48 private HttpClient .Responseconnection;48 private HttpClient connection; 49 49 50 50 /** … … 107 107 sign(client); 108 108 synchronized (this) { 109 connection = client.connect(); 109 connection = client; 110 connection.connect(); 110 111 } 111 112 112 if (connection.getResponse Code() == HttpURLConnection.HTTP_UNAUTHORIZED)113 if (connection.getResponse().getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) 113 114 throw new OsmApiException(HttpURLConnection.HTTP_UNAUTHORIZED, 114 115 tr("Retrieving user details with Access Token Key ''{0}'' was rejected.", token.getKey()), null); 115 116 116 if (connection.getResponse Code() == HttpURLConnection.HTTP_FORBIDDEN)117 if (connection.getResponse().getResponseCode() == HttpURLConnection.HTTP_FORBIDDEN) 117 118 throw new OsmApiException(HttpURLConnection.HTTP_FORBIDDEN, 118 119 tr("Retrieving user details with Access Token Key ''{0}'' was forbidden.", token.getKey()), null); 119 120 120 if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) 121 throw new OsmApiException(connection.getResponseCode(), connection.getHeaderField("Error"), null); 122 Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(connection.getContent()); 121 if (connection.getResponse().getResponseCode() != HttpURLConnection.HTTP_OK) 122 throw new OsmApiException(connection.getResponse().getResponseCode(), 123 connection.getResponse().getHeaderField("Error"), null); 124 Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(connection.getResponse().getContent()); 123 125 return OsmServerUserInfoReader.buildFromXML(d); 124 126 } catch (SAXException | ParserConfigurationException e) { -
trunk/src/org/openstreetmap/josm/gui/preferences/server/ApiUrlTestTask.java
r9172 r9309 36 36 private boolean success; 37 37 private final Component parent; 38 private HttpClient .Responseconnection;38 private HttpClient connection; 39 39 40 40 /** … … 177 177 178 178 synchronized (this) { 179 connection = HttpClient.create(capabilitiesUrl).connect(); 180 } 181 182 if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) { 183 alertInvalidServerResult(connection.getResponseCode()); 179 connection = HttpClient.create(capabilitiesUrl); 180 connection.connect(); 181 } 182 183 if (connection.getResponse().getResponseCode() != HttpURLConnection.HTTP_OK) { 184 alertInvalidServerResult(connection.getResponse().getResponseCode()); 184 185 return; 185 186 } 186 187 187 188 try { 188 Capabilities.CapabilitiesParser.parse(new InputSource(connection.get Content()));189 Capabilities.CapabilitiesParser.parse(new InputSource(connection.getResponse().getContent())); 189 190 } catch (SAXException | ParserConfigurationException e) { 190 191 Main.warn(e.getMessage());
Note:
See TracChangeset
for help on using the changeset viewer.