Skip to content

Commit a9e5e95

Browse files
committed
Set user agent for osm tile requests'
1 parent 25ca90c commit a9e5e95

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/groovy/geoscript/layer/OSM.groovy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,13 @@ class OSM extends ImageTileLayer {
7575
ImageTile tile = new ImageTile(z, x, y)
7676
String baseUrl = getBaseUrl()
7777
URL url = new URL("${baseUrl}/${z}/${x}/${y}.${imageType}")
78-
url.withInputStream {input ->
79-
tile.data = input.bytes
78+
URLConnection urlConnection = url.openConnection()
79+
urlConnection.setRequestProperty("User-Agent", "GeoScript Groovy")
80+
InputStream inputStream = urlConnection.inputStream
81+
try {
82+
tile.data = inputStream.bytes
83+
} finally {
84+
inputStream.close()
8085
}
8186
tile
8287
}

0 commit comments

Comments
 (0)