*/
public static HTTPMessageEntities retrieveRequestHeaders(
final WebDriverRequest request,
XMLPipelineContext xmlPipelineContext) throws HTTPException {
// will store any headers
final HTTPMessageEntities headers =
HTTPFactory.getDefaultInstance()
.createHTTPMessageEntities();
// create an entity adder that adds request headers to the executor
DerivableHTTPMessageEntityAdder headerAdder =
new DerivableHTTPMessageEntityAdder() {
// javadoc inherited
public void addDerivableHTTPMessageEntity(
DerivableHTTPMessageEntity header)
throws HTTPException {
// obtain the outgoing headers
Header[] headerArray = acquireOutgoingHeaders(header,
request);
for (int i = 0; i < headerArray.length; i++) {
headers.add(headerArray[i]);
}
}
};
// add the headers
addHTTPMessageEntities(WebRequestHeader.class, headerAdder,
xmlPipelineContext);
if (headers.size() == 0 && request != null &&
request.getHeaders() != null) {
for(Iterator i = request.getHeaders().iterator();
i.hasNext(); ) {
Header header = (Header) i.next();
headers.add(header);
}
}
// add visited MCS instances header
final String instances = (String) xmlPipelineContext.getProperty(
URLConfigurationFactory.VISITED_MCS_INSTANCES_HEADER_NAME);
if (instances != null) {
final Header header = HTTPFactory.getDefaultInstance().createHeader(
URLConfigurationFactory.VISITED_MCS_INSTANCES_HEADER_NAME);
header.setValue(instances);
headers.put(header);
}
// return the headers
return headers;
}