Ticket #3580: auth.patch
File auth.patch, 2.2 KB (added by , 15 years ago) |
---|
-
src/org/openstreetmap/josm/io/OsmApi.java
162 162 cancel = false; 163 163 initAuthentication(); 164 164 try { 165 String s = sendRequest("GET", "capabilities", null,monitor );165 String s = sendRequest("GET", "capabilities", null,monitor, false); 166 166 InputSource inputSource = new InputSource(new StringReader(s)); 167 167 SAXParserFactory.newInstance().newSAXParser().parse(inputSource, new CapabilitiesParser()); 168 168 if (capabilities.supportsVersion("0.6")) { … … 458 458 return Math.max(ret,0); 459 459 } 460 460 461 private String sendRequest(String requestMethod, String urlSuffix,String requestBody, ProgressMonitor monitor) throws OsmTransferException { 462 return sendRequest(requestMethod, urlSuffix, requestBody, monitor, true); 463 } 464 461 465 /** 462 466 * Generic method for sending requests to the OSM API. 463 467 * … … 473 477 * @exception OsmTransferException if the HTTP return code was not 200 (and retries have 474 478 * been exhausted), or rewrapping a Java exception. 475 479 */ 476 private String sendRequest(String requestMethod, String urlSuffix,String requestBody, ProgressMonitor monitor ) throws OsmTransferException {480 private String sendRequest(String requestMethod, String urlSuffix,String requestBody, ProgressMonitor monitor, boolean doAuthenticate) throws OsmTransferException { 477 481 StringBuffer responseBody = new StringBuffer(); 478 479 482 int retries = getMaxRetries(); 480 483 481 484 while(true) { // the retry loop … … 485 488 activeConnection = (HttpURLConnection)url.openConnection(); 486 489 activeConnection.setConnectTimeout(15000); 487 490 activeConnection.setRequestMethod(requestMethod); 488 addAuth(activeConnection); 491 if (doAuthenticate) { 492 addAuth(activeConnection); 493 } 489 494 490 495 if (requestMethod.equals("PUT") || requestMethod.equals("POST") || requestMethod.equals("DELETE")) { 491 496 activeConnection.setDoOutput(true);