Changeset 12557 in josm for trunk/src/org
- Timestamp:
- 2017-08-02T20:41:01+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/NameFinder.java
r11746 r12557 18 18 import org.openstreetmap.josm.data.osm.PrimitiveId; 19 19 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; 20 import org.openstreetmap.josm.data.preferences.StringProperty; 20 21 import org.openstreetmap.josm.tools.HttpClient; 22 import org.openstreetmap.josm.tools.HttpClient.Response; 21 23 import org.openstreetmap.josm.tools.OsmUrlToBounds; 22 24 import org.openstreetmap.josm.tools.UncheckedParseException; … … 34 36 35 37 /** 36 * Nominatim URL. 38 * Nominatim default URL. 37 39 */ 38 40 public static final String NOMINATIM_URL = "https://nominatim.openstreetmap.org/search?format=xml&q="; 41 42 /** 43 * Nominatim URL property. 44 * @since xxx 45 */ 46 public static final StringProperty NOMINATIM_URL_PROP = new StringProperty("nominatim-url", NOMINATIM_URL); 39 47 40 48 private NameFinder() { … … 48 56 */ 49 57 public static List<SearchResult> queryNominatim(final String searchExpression) throws IOException { 50 return query(new URL(NOMINATIM_URL + Utils.encodeUrl(searchExpression))); 58 return query(new URL(NOMINATIM_URL_PROP.get() + Utils.encodeUrl(searchExpression))); 51 59 } 52 60 … … 59 67 public static List<SearchResult> query(final URL url) throws IOException { 60 68 final HttpClient connection = HttpClient.create(url); 61 connection.connect(); 62 try (Reader reader = connection.getResponse().getContentReader()) { 69 Response response = connection.connect(); 70 if (response.getResponseCode() >= 400) { 71 throw new IOException(response.getResponseMessage() + ": " + response.fetchContent()); 72 } 73 try (Reader reader = response.getContentReader()) { 63 74 return parseSearchResults(reader); 64 75 } catch (ParserConfigurationException | SAXException ex) { -
trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java
r12475 r12557 30 30 import org.openstreetmap.josm.data.projection.Projections; 31 31 import org.openstreetmap.josm.tools.HttpClient; 32 import org.openstreetmap.josm.tools.HttpClient.Response; 32 33 import org.openstreetmap.josm.tools.Utils; 33 34 import org.w3c.dom.Document; … … 226 227 } 227 228 228 final String incomingData = HttpClient.create(getCapabilitiesUrl).connect().fetchContent(); 229 final Response response = HttpClient.create(getCapabilitiesUrl).connect(); 230 final String incomingData = response.fetchContent(); 229 231 Main.debug("Server response to Capabilities request:"); 230 232 Main.debug(incomingData); 233 234 if (response.getResponseCode() >= 400) { 235 throw new WMSGetCapabilitiesException(response.getResponseMessage(), incomingData); 236 } 231 237 232 238 try {
Note:
See TracChangeset
for help on using the changeset viewer.