Changeset 9309 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2016-01-04T20:51:45+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/HttpClient.java
r9274 r9309 47 47 private boolean useCache; 48 48 private String reasonForRequest; 49 private transient HttpURLConnection connection; // to allow disconnecting before `response` is set 50 private transient Response response; 49 51 50 52 private HttpClient(URL url, String requestMethod) { … … 75 77 } 76 78 final HttpURLConnection connection = (HttpURLConnection) url.openConnection(); 79 this.connection = connection; 77 80 connection.setRequestMethod(requestMethod); 78 81 connection.setRequestProperty("User-Agent", Version.getInstance().getFullAgentString()); … … 148 151 } 149 152 } 150 Responseresponse = new Response(connection, progressMonitor);153 response = new Response(connection, progressMonitor); 151 154 successfulConnection = true; 152 155 return response; … … 156 159 } 157 160 } 161 } 162 163 /** 164 * Returns the HTTP response which is set only after calling {@link #connect()}. 165 * Calling this method again, returns the identical object (unless another {@link #connect()} is performed). 166 * 167 * @return the HTTP response 168 * @since 9309 169 */ 170 public Response getResponse() { 171 return response; 158 172 } 159 173 … … 381 395 */ 382 396 public void disconnect() { 383 // TODO is this block necessary for disconnecting? 384 // Fix upload aborts - see #263 385 connection.setConnectTimeout(100); 386 connection.setReadTimeout(100); 387 try { 388 Thread.sleep(100); 389 } catch (InterruptedException ex) { 390 Main.warn("InterruptedException in " + getClass().getSimpleName() + " during cancel"); 391 } 392 393 connection.disconnect(); 397 HttpClient.disconnect(connection); 394 398 } 395 399 } … … 611 615 } 612 616 } 617 618 /** 619 * @see HttpURLConnection#disconnect() 620 * @since 9309 621 */ 622 public void disconnect() { 623 HttpClient.disconnect(connection); 624 } 625 626 private static void disconnect(final HttpURLConnection connection) { 627 // Fix upload aborts - see #263 628 connection.setConnectTimeout(100); 629 connection.setReadTimeout(100); 630 try { 631 Thread.sleep(100); 632 } catch (InterruptedException ex) { 633 Main.warn("InterruptedException in " + HttpClient.class + " during cancel"); 634 } 635 connection.disconnect(); 636 } 613 637 }
Note:
See TracChangeset
for help on using the changeset viewer.