Ticket #11548: HttpURL.patch
File HttpURL.patch, 2.5 KB (added by , 9 years ago) |
---|
-
src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
318 318 return true; 319 319 } 320 320 321 HttpURLConnection urlConn = getURLConnection();321 URLConnection urlConn = getURLConnection(); 322 322 323 323 if (isObjectLoadable() && 324 324 (now - attributes.getLastModification()) <= ABSOLUTE_EXPIRE_TIME_LIMIT) { … … 327 327 if (isObjectLoadable() && attributes.getEtag() != null) { 328 328 urlConn.addRequestProperty("If-None-Match", attributes.getEtag()); 329 329 } 330 if ( urlConn.getResponseCode() == 304) {330 if (responseCode(urlConn) == 304) { 331 331 // If isModifiedSince or If-None-Match has been set 332 332 // and the server answers with a HTTP 304 = "Not Modified" 333 333 log.log(Level.FINE, "JCS - IfModifiedSince/Etag test: local version is up to date: {0}", getUrl()); … … 348 348 attributes = parseHeaders(urlConn); 349 349 350 350 for (int i = 0; i < 5; ++i) { 351 if ( urlConn.getResponseCode() == 503) {351 if (responseCode(urlConn) == 503) { 352 352 Thread.sleep(5000+(new Random()).nextInt(5000)); 353 353 continue; 354 354 } 355 355 356 attributes.setResponseCode( urlConn.getResponseCode());356 attributes.setResponseCode(responseCode(urlConn)); 357 357 byte[] raw = read(urlConn); 358 358 359 if (isResponseLoadable(urlConn.getHeaderFields(), urlConn.getResponseCode(), raw)) {359 if (isResponseLoadable(urlConn.getHeaderFields(), responseCode(urlConn), raw)) { 360 360 // we need to check cacheEmpty, so for cases, when data is returned, but we want to store 361 361 // as empty (eg. empty tile images) to save some space 362 362 cacheData = createCacheEntry(raw); … … 521 521 public void handleJobCancellation() { 522 522 finishLoading(LoadResult.CANCELED); 523 523 } 524 525 private int responseCode(URLConnection urlConn) throws IOException { 526 if (urlConn instanceof HttpURLConnection) { 527 return ((HttpURLConnection) urlConn).getResponseCode(); 528 } else { 529 return 500; 530 } 531 } 524 532 }