HTTPFactory factory = HTTPFactory.getDefaultInstance();
final String headerName = httpClientHeader.getName();
final List values = HttpClientUtils.getHeaderValueList(httpClientHeader);
if (values.size() == 0) {
Header header = factory.createHeader(headerName);
headers.add(header);
} else {
if (valueList) {
for (Iterator iter = values.iterator(); iter.hasNext(); ) {
final Header header = factory.createHeader(headerName);
final String value = (String) iter.next();
header.setValue(value);
headers.add(header);
}
} else {
StringBuffer reconstitutedHeader = new StringBuffer();
Iterator it = values.iterator();
while (it.hasNext()) {
if (reconstitutedHeader.length() > 0) {
reconstitutedHeader.append(',');
}
reconstitutedHeader.append(it.next());
}
final Header header = factory.createHeader(headerName);
header.setValue(reconstitutedHeader.toString());
headers.add(header);
}
}
}