// if browser closes stream, we should detect it and kill process...
try
{
// read any headers off the top of our input stream
LineInput li = new LineInput(p.getInputStream());
HttpFields fields=new HttpFields();
fields.read(li);
String ContentStatus = "Status";
String redirect = fields.get(HttpFields.__Location);
String status = fields.get(ContentStatus);
if (status!=null)
{
log.debug("Found a Status header - setting status on response");
fields.remove(ContentStatus);
// NOTE: we ignore any reason phrase, otherwise we
// would need to use res.sendError() selectively.
int i = status.indexOf(' ');
if (i>0)
status = status.substring(0,i);
res.setStatus(Integer.parseInt(status));
}
// copy remaining headers into response...
for (Iterator i=fields.iterator(); i.hasNext();)
{
HttpFields.Entry e=(HttpFields.Entry)i.next();
res.addHeader(e.getKey(),e.getValue());
}