// If we are at an illegal depth, don't include.
Integer depth = (Integer) variables.get("depth") ;
int maxDepth = ((Integer)variables.get("maxDepth")).intValue() ;
if(maxDepth != 0 && depth.intValue()>maxDepth) {
Reply reply = ssiframe
.createCommandReply(request,HTTP.OK) ;
reply.setContent("[recursion depth limit exceeded]") ;
handleSimpleIMS(request,reply) ;
return reply ;
}
Request subReq = null ;
Reply subRep = null ;
try {
// Prepare an internal request
subReq =
prepareRequest(request,
new URL(ssiframe.getURL(request)
, targetName)
.toString(),
variables,
depth) ;
// Obtain a reply for it
subRep =
(Reply) ssiframe.getFileResource().getServer().perform(subReq) ;
// If it has status NOT_MODIFIED, it means the included
// ssiframe was also SSI, and we don't calculate anything
// here.
// Otherwise, see if we can reply NOT_MODIFIED.
if(subRep.getStatus() != HTTP.NOT_MODIFIED) {
long ims = request.getIfModifiedSince() ;
if(ims==-1) {
Long IMS = (Long)
request.getState(STATE_IF_MODIFIED_SINCE) ;
if(IMS != null) ims = IMS.longValue() ;
}
long lmd = subRep.getLastModified() ;
lmd -= lmd % 1000 ; // this is annoying
if(ims != -1 && lmd != -1 && ims>=lmd) {
subRep.setStatus(HTTP.NOT_MODIFIED) ;
//close the stream
subRep.openStream().close();
}
}
return subRep ;
} catch(MalformedURLException ex) {
Reply reply = ssiframe
.createCommandReply(request,HTTP.OK) ;
reply.setContent("[malformed URL]") ;
handleSimpleIMS(request,reply) ;
return reply ;
} catch(Exception ex) {
Reply reply = ssiframe
.createCommandReply(request,HTTP.OK) ;
reply.setContent("[error including: "+targetName+"]") ;
handleSimpleIMS(request,reply) ;
return reply ;
}
}