Search code examples
androidandroid-ion

Ion Android getHeaders


How do I get a specific header using the Ion network library for Android?

This is what I'm trying:

...
.setCallback(new FutureCallback<Response<String>>() {
    @Override
    public void onCompleted(Exception e, Response<String> result) {
        System.out.println("header: " + result.getHeaders().message("mykey"));
    }
});

Solution

  • message(String) sets the HTTP response message. I should make that internal to avoid confusion.

    Use

    getHeaders().getHeaders().get(String)
    

    It's a bit obtuse at the moment, will need to clean that API up in the next release.