b.deleteCharAt(0);
}
b.insert(0, "www/");
String resourcePath = b.toString();
LOG.info("HTTP File Server Request [" + resourcePath + "]");
HttpResponse response = contentCache.get(resourcePath);
if(response==null) {
synchronized(contentCache) {
response = contentCache.get(resourcePath);
if(response==null) {
is = classLoader.getResourceAsStream(b.toString());
if(is.available()==0) {
sendError(ctx, NOT_FOUND);
return null;
}
baos = new ByteArrayOutputStream(is.available());
int bt = -1;
while((bt=is.read())!=-1) {
baos.write(bt);
}
byte[] content = baos.toByteArray();
response = new DefaultHttpResponse(HTTP_1_1, OK);
setContentLength(response, content.length);
setContentTypeHeader(response, resourcePath);
setDateAndCacheHeaders(response, resourcePath);
response.setContent(ChannelBuffers.wrappedBuffer(content));
contentCache.put(resourcePath, response);
}
}
}
Channel ch = e.getChannel();