}
Map<String, Object> convertHeadersToMap(Header[] headersArray, String uri)
throws URISyntaxException
{
Map<String, Object> headersMap = new CaseInsensitiveHashMap();
for (int i = 0; i < headersArray.length; i++)
{
final Header header = headersArray[i];
// Cookies are a special case because there may be more than one
// cookie.
if (HttpConnector.HTTP_COOKIES_PROPERTY.equals(header.getName())
|| HttpConstants.HEADER_COOKIE.equals(header.getName()))
{
putCookieHeaderInMapAsAServer(headersMap, header, uri);
}
else if (HttpConstants.HEADER_COOKIE_SET.equals(header.getName()))
{
putCookieHeaderInMapAsAClient(headersMap, header, uri);
}
else
{
if (headersMap.containsKey(header.getName()))
{
if (headersMap.get(header.getName()) instanceof String)
{
// concat
headersMap.put(header.getName(),
headersMap.get(header.getName()) + "," + header.getValue());
}
else
{
// override
headersMap.put(header.getName(), header.getValue());
}
}
else
{
headersMap.put(header.getName(), header.getValue());
}
}
}
return headersMap;
}