Example usage for com.google.gwt.xhr.client XMLHttpRequest getResponseHeader

List of usage examples for com.google.gwt.xhr.client XMLHttpRequest getResponseHeader

Introduction

In this page you can find the example usage for com.google.gwt.xhr.client XMLHttpRequest getResponseHeader.

Prototype

public abstract String getResponseHeader(String header);

Source Link

Document

Gets an HTTP response header.

Usage

From source file:playn.http.HttpHtml.java

License:Apache License

private void gotResponse(final HttpRequest req, XMLHttpRequest xhr, String responseBody,
        final Callback<HttpResponse> callback) throws IOException {
    int statusCode = -1;
    String statusLineMessage = null;
    Map<String, String> responseHeaders = new HashMap<String, String>();
    try {//from  w ww . j  a  v  a 2 s  . c  o m
        statusCode = xhr.getStatus();
        statusLineMessage = xhr.getStatusText();
        for (String headerName : getAllResponseHeaderNames(xhr)) {
            String value = xhr.getResponseHeader(headerName);
            responseHeaders.put(headerName, value);
        }
        HttpResponse response = new HttpResponse(statusCode, statusLineMessage, responseHeaders, responseBody);
        callback.onSuccess(response);
    } catch (Throwable t) {
        throw new HttpException(statusCode, statusLineMessage, responseBody, t, HttpErrorType.SERVER_ERROR);
    }
}