}
}
if (request.getMethod().equals("TRACE")) {
// check if the resource can be proxied
boolean doit = true;
LookupState ls = new LookupState(request);
LookupResult lr = new LookupResult(root.getResourceReference());
try {
if ( root.lookup(ls, lr) ) {
ResourceReference target = lr.getTarget();
if (target != null) {
try {
// this is plain ugly and won't work for proxy
// not based on this resource
// do we need another way to to this?
FramedResource fr = (FramedResource) target.lock();
Class cff = Class.forName(
"org.w3c.jigsaw.proxy.ForwardFrame");
doit = (fr.getFrameReference(cff) == null);
} catch (Exception ex) {
// fail miserably to the fallback
} finally {
target.unlock();
}
}
}
} catch (Exception ex) {};
if (doit) {
Reply reply = request.makeReply(HTTP.OK);
reply.setNoCache(); // don't cache this
reply.setMaxAge(-1);
// Dump the request as the body
// Removed unused headers:
// FIXME should be something else for chuncked stream
ByteArrayOutputStream ba = new ByteArrayOutputStream();
try {
reply.setContentType(new MimeType("message/http"));
request.dump(ba);
reply.setContentLength(ba.size());
} catch (Exception ex) {
ex.printStackTrace();
}
reply.setStream(new ByteArrayInputStream(ba.toByteArray()));
return reply;
}
}
// Create a lookup state, and a lookup result:
ProtocolException error = null;
LookupState ls = null;
LookupResult lr = null;
// Run the lookup algorithm of root resource:
// catch exception to get error (FIXME)
try {
lr = new LookupResult(root.getResourceReference());
ls = new LookupState(request);
if ( root.lookup(ls, lr) ) {
if (lr.hasReply())
return lr.getReply();
}