Search in sources :

Example 1 with SimpleHttpClientResponse

use of org.forgerock.http.client.response.SimpleHttpClientResponse in project OpenAM by OpenRock.

the class RestletHttpClient method createHttpClientResponse.

private HttpClientResponse createHttpClientResponse(Response response) {
    Integer statusCode = null;
    String reasonPhrase = null;
    Map<String, String> headersMap = null;
    Map<String, String> cookiesMap = null;
    if (response.getStatus() != null) {
        statusCode = response.getStatus().getCode();
        reasonPhrase = response.getStatus().getDescription();
    }
    String messageBody = response.getEntityAsText();
    Series headersSeries = (Series) response.getAttributes().get("org.restlet.http.headers");
    if (headersSeries != null) {
        headersMap = headersSeries.getValuesMap();
    }
    Series<CookieSetting> cookieSettings = response.getCookieSettings();
    if (cookieSettings != null) {
        cookiesMap = response.getCookieSettings().getValuesMap();
    }
    return new SimpleHttpClientResponse(statusCode, reasonPhrase, headersMap, messageBody, cookiesMap);
}
Also used : Series(org.restlet.util.Series) SimpleHttpClientResponse(org.forgerock.http.client.response.SimpleHttpClientResponse)

Aggregations

SimpleHttpClientResponse (org.forgerock.http.client.response.SimpleHttpClientResponse)1 Series (org.restlet.util.Series)1