exchange.sendError(ioe);
}
};
IHttpRequest request = exchange.getRequest();
try {
Map<String, List<String>> cookieHeaders = cookieManager.get(getRequestURI(exchange));
for (Entry<String, List<String>> entry : cookieHeaders.entrySet()) {
if (!entry.getValue().isEmpty()) {
StringBuilder sb = new StringBuilder();
List<String> cookies = entry.getValue();
for (int i = 0; i < cookies.size(); i++) {
sb.append(cookies.get(i));
if ((i +1) < cookies.size()) {
sb.append("; ");
}
}
if ((request.getHeader("Cookie") != null) && Boolean.parseBoolean(System.getProperty(COOKIE_WARNING_KEY, "true"))) {
LOG.warning("cookie is set manually and auto handle cookie is activate " +
"(hint: deactivate auto handling cookie by calling <httpClient>.setAutoHandleCookies(false) or " +
"suppress this message by setting system property 'org.xlightweb.client.cookieHandler.cookieWarning=false')");
}
request.addHeader(entry.getKey(), sb.toString());
}
}
} catch (URISyntaxException ue) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("invcalid URI. ignore handling cookies " + ue.toString());