improved debugging output
This commit is contained in:
parent
9a848e3425
commit
2af613a28b
|
@ -168,5 +168,11 @@ public interface HttpContent
|
|||
{
|
||||
_resource.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("%s@%x{r=%s}",this.getClass().getSimpleName(),hashCode(),_resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -643,6 +643,9 @@ public class HttpOutput extends ServletOutputStream implements Runnable
|
|||
|
||||
if (buffer!=null)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("sendContent({}=={},{},direct={})",httpContent,BufferUtil.toDetailString(buffer),callback,_channel.useDirectBuffers());
|
||||
|
||||
sendContent(buffer,callback);
|
||||
return;
|
||||
}
|
||||
|
@ -650,6 +653,8 @@ public class HttpOutput extends ServletOutputStream implements Runnable
|
|||
ReadableByteChannel rbc=httpContent.getReadableByteChannel();
|
||||
if (rbc!=null)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("sendContent({}=={},{},direct={})",httpContent,rbc,callback,_channel.useDirectBuffers());
|
||||
// Close of the rbc is done by the async sendContent
|
||||
sendContent(rbc,callback);
|
||||
return;
|
||||
|
@ -658,6 +663,8 @@ public class HttpOutput extends ServletOutputStream implements Runnable
|
|||
InputStream in = httpContent.getInputStream();
|
||||
if ( in!=null )
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("sendContent({}=={},{},direct={})",httpContent,in,callback,_channel.useDirectBuffers());
|
||||
sendContent(in,callback);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -504,7 +504,7 @@ public class ResourceCache
|
|||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("%s %s %d %s %s",_resource,_resource.exists(),_resource.lastModified(),_contentType,_lastModifiedBytes);
|
||||
return String.format("CachedContent@%x{r=%s,e=%b,lm=%d,ct=%s}",hashCode(),_resource,_resource.exists(),BufferUtil.toString(_lastModifiedBytes),_contentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -494,7 +494,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
}
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("uri="+request.getRequestURI()+" resource="+resource+(content!=null?" content":""));
|
||||
LOG.debug(String.format("uri=%s, resource=%s, content=%s",request.getRequestURI(),resource,content));
|
||||
|
||||
// Handle resource
|
||||
if (resource==null || !resource.exists())
|
||||
|
@ -863,7 +863,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
throws IOException
|
||||
{
|
||||
final long content_length = (content==null)?resource.length():content.getContentLength();
|
||||
|
||||
|
||||
// Get the output stream (or writer)
|
||||
OutputStream out =null;
|
||||
boolean written;
|
||||
|
@ -881,6 +881,9 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
out = new WriterOutputStream(response.getWriter());
|
||||
written=true; // there may be data in writer buffer, so assume written
|
||||
}
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug(String.format("sendData content=%s out=%s async=%b",content,out,request.isAsyncSupported()));
|
||||
|
||||
if ( reqRanges == null || !reqRanges.hasMoreElements() || content_length<0)
|
||||
{
|
||||
|
@ -935,6 +938,12 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
|
|||
LOG.warn(x);
|
||||
context.complete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("DefaultServlet@%x$CB", DefaultServlet.this.hashCode());
|
||||
}
|
||||
});
|
||||
}
|
||||
// otherwise write content blocking
|
||||
|
|
|
@ -324,22 +324,22 @@ public class GzipHttpOutput extends HttpOutput
|
|||
{
|
||||
private final ByteBuffer _input;
|
||||
private final ByteBuffer _content;
|
||||
private final boolean _complete;
|
||||
private final boolean _last;
|
||||
public GzipBufferCB(ByteBuffer content, boolean complete, Callback callback)
|
||||
{
|
||||
super(callback);
|
||||
_input=getHttpChannel().getByteBufferPool().acquire(Math.min(_factory.getBufferSize(),content.remaining()),false);
|
||||
_content=content;
|
||||
_complete=complete;
|
||||
_last=complete;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Action process() throws Exception
|
||||
{
|
||||
if (_deflater.needsInput())
|
||||
{
|
||||
{
|
||||
if (BufferUtil.isEmpty(_content))
|
||||
{
|
||||
{
|
||||
if (_deflater.finished())
|
||||
{
|
||||
_factory.recycle(_deflater);
|
||||
|
@ -349,38 +349,51 @@ public class GzipHttpOutput extends HttpOutput
|
|||
return Action.SUCCEEDED;
|
||||
}
|
||||
|
||||
if (!_complete)
|
||||
if (!_last)
|
||||
{
|
||||
return Action.SUCCEEDED;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BufferUtil.clearToFill(_input);
|
||||
BufferUtil.put(_content,_input);
|
||||
int took=BufferUtil.put(_content,_input);
|
||||
BufferUtil.flipToFlush(_input,0);
|
||||
|
||||
if (took==0)
|
||||
throw new IllegalStateException();
|
||||
|
||||
byte[] array=_input.array();
|
||||
int off=_input.arrayOffset()+_input.position();
|
||||
int len=_input.remaining();
|
||||
|
||||
_crc.update(array,off,len);
|
||||
_deflater.setInput(array,off,len);
|
||||
if (_complete && BufferUtil.isEmpty(_content))
|
||||
if (_last && BufferUtil.isEmpty(_content))
|
||||
_deflater.finish();
|
||||
}
|
||||
}
|
||||
|
||||
BufferUtil.compact(_buffer);
|
||||
int off=_buffer.arrayOffset()+_buffer.limit();
|
||||
int len=_buffer.capacity()-_buffer.limit() - (_complete?8:0);
|
||||
int len=_buffer.capacity()-_buffer.limit() - (_last?8:0);
|
||||
int produced=_deflater.deflate(_buffer.array(),off,len,Deflater.NO_FLUSH);
|
||||
if (produced==0)
|
||||
{
|
||||
LOG.warn(String.format("AsyncGzipFilter NO PROGRESS!!!! content=%s, input=%s, last=%b, deflater=%s finished=%b",
|
||||
BufferUtil.toDetailString(_content),
|
||||
BufferUtil.toDetailString(_input),
|
||||
_last,
|
||||
_deflater,
|
||||
_deflater.finished()));
|
||||
}
|
||||
|
||||
_buffer.limit(_buffer.limit()+produced);
|
||||
boolean complete=_deflater.finished();
|
||||
boolean finished=_deflater.finished();
|
||||
|
||||
if (complete)
|
||||
if (finished)
|
||||
addTrailer();
|
||||
|
||||
superWrite(_buffer,complete,this);
|
||||
superWrite(_buffer,finished,this);
|
||||
return Action.SCHEDULED;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue