Example usage for org.apache.http.client.methods CloseableHttpResponse getLocale

List of usage examples for org.apache.http.client.methods CloseableHttpResponse getLocale

Introduction

In this page you can find the example usage for org.apache.http.client.methods CloseableHttpResponse getLocale.

Prototype

Locale getLocale();

Source Link

Usage

From source file:com.lehman.ic9.net.httpClient.java

/**
 * Updates the Javascript response object.
 * @param info is the Javascript response object to update.
 * @param resp is a ClosableHttpResponse object with the actual response.
 * @throws NoSuchMethodException Exception
 * @throws ScriptException Exception/* w  ww .j a v  a2  s  .  c  o m*/
 */
private void getResponseInfo(Map<String, Object> info, CloseableHttpResponse resp)
        throws NoSuchMethodException, ScriptException {
    // Locale
    Locale jloc = resp.getLocale();
    info.put("locale", jloc.toLanguageTag());

    info.put("protocol", resp.getProtocolVersion().toString());
    info.put("protocolMajor", resp.getProtocolVersion().getMajor());
    info.put("protocolMinor", resp.getProtocolVersion().getMinor());
    info.put("statusLine", resp.getStatusLine().toString());
    info.put("statusCode", resp.getStatusLine().getStatusCode());
    info.put("statusReasonPhrase", resp.getStatusLine().getReasonPhrase());

    // Headers.
    Map<String, Object> hmap = this.eng.newObj(null);
    Header hdrs[] = resp.getAllHeaders();
    for (Header hdr : hdrs) {
        hmap.put(hdr.getName(), hdr.getValue());
    }
    info.put("headers", hmap);

    // Cookies
    Object clist = this.eng.newList();
    this.jsobj.put("cookies", clist);
    for (Cookie C : this.cs.getCookies()) {
        Object nc = this.getApacheCookie(C);
        this.eng.invokeMethod(clist, "push", nc);
    }
}