Skip to content

Commit

Permalink
Add default User-Agent header to HTTP requests on Android (#2278)
Browse files Browse the repository at this point in the history
* Add a default User-Agent header in DefaultHttpHandler

* Clean up raster-simple demo scene
  • Loading branch information
matteblair authored Jul 18, 2021
1 parent 3eefe6e commit 47db6b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public void onResponse(@NonNull final Call call, final Response response) {
}
};
final Request.Builder builder = new Request.Builder().url(httpUrl);
// Some tile endpoints treat requests as "unauthorized" if they have no User-Agent header,
// so add a default value to every request. Users can override this in configureRequest().
builder.addHeader("User-Agent", "tangram");
configureRequest(httpUrl, builder);
final Request request = builder.build();
Call call = okClient.newCall(request);
Expand Down
9 changes: 4 additions & 5 deletions scenes/raster-simple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ global:
mapzen_api_key: ''

sources:
stamen-terrain:
osm-raster:
type: Raster
#url: http://a.tile.stamen.com/terrain-background/{z}/{x}/{y}.jpg
url: http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
url: https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
url_subdomains: [a, b, c]

layers:
terrain:
data: { source: stamen-terrain }
data:
source: osm-raster
draw:
raster:
#color: [0.8, 0.8, 0.8]
order: 0 # draw on bottom

0 comments on commit 47db6b8

Please sign in to comment.