Example usage for com.google.gwt.xhr2.client Header getValue

List of usage examples for com.google.gwt.xhr2.client Header getValue

Introduction

In this page you can find the example usage for com.google.gwt.xhr2.client Header getValue.

Prototype

public abstract String getValue();

Source Link

Document

Returns the value of the HTTP header.

Usage

From source file:org.rest.client.ui.desktop.ResponseViewImpl.java

License:Apache License

/**
 * Check if in response headers is some header defined as JSON header.
 * @param headers/* ww  w  .  jav a2s. com*/
 * @return
 */
private boolean isJSONHeader(Header[] headers) {
    String[] jsonHeadersDefinitions = JSONHeadersUtils.getJSONHeadersListSynch();
    for (Header header : headers) {
        if (header == null) {
            continue;
        }
        String name = header.getName().toLowerCase();
        if (name.equals("content-type")) {
            String value = header.getValue().toLowerCase();
            if (value.contains("+json")) {
                return true;
            }
            for (String headerDef : jsonHeadersDefinitions) {
                if (value.contains(headerDef)) {
                    return true;
                }
            }
            return false;
        }
    }
    return false;
}

From source file:org.rest.client.ui.desktop.ResponseViewImpl.java

License:Apache License

private boolean isImageHeader(Header[] headers) {
    boolean result = false;
    for (Header header : headers) {
        if (!header.getName().toLowerCase().equals("content-type"))
            continue;
        if (header.getValue().startsWith("image/")) {
            result = true;// ww w. j av a 2  s  .c om
        }
    }
    return result;
}

From source file:org.rest.client.ui.desktop.ResponseViewImpl.java

License:Apache License

private boolean isJavaScriptHeader(Header[] headers) {
    boolean result = false;
    for (Header header : headers) {
        if (!header.getName().toLowerCase().equals("content-type"))
            continue;
        if (header.getValue().contains("javascript")) {
            result = true;/*  w  w  w  . j a va  2  s.  c  o  m*/
        }
    }
    return result;
}

From source file:org.rest.client.ui.desktop.ResponseViewImpl.java

License:Apache License

private String getRequestContentType(String defaultEncodeing) {
    if (requestEncoding != null) {
        return requestEncoding;
    }//from   w w  w  . ja  va 2s  .  co m
    Header[] headers = response.getHeaders();
    for (Header header : headers) {
        if (header.getName().toLowerCase().equals("content-type")) {
            defaultEncodeing = header.getValue().split(";")[0];
            break;
        }
    }
    requestEncoding = defaultEncodeing;
    return defaultEncodeing;
}