Skip to content

Allow customization of request headers in HttpHandler #1542

@sarahsnow1

Description

@sarahsnow1

Currently there isn't a way to add custom request headers in HttpHandler subclasses because the underlying http client is private. The Android SDK will need this ability when implementing mapzen/android#382 and EM relies on the ability to customize headers when adding the "do not track" header https://github.com/mapzen/eraser-map/blob/master/app/src/main/kotlin/com/mapzen/erasermap/model/TileHttpHandler.kt#L19

I propose adding a header Map parameter to onRequest and updating the implementation to construct a Request using this map:

public boolean onRequest(String url, Map<String, String> headers, Callback cb) {
  Request request = new Request.Builder()
    .url(url)
    .headers(Headers.of(headers))
    .build();
  okClient.newCall(request).enqueue(cb);
  return true;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions