This commit is contained in:
Redkale
2017-07-11 11:59:12 +08:00
parent 2f98cd1ab5
commit 77057df25d

View File

@@ -704,8 +704,8 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
final String match = request.getHeader("If-None-Match"); final String match = request.getHeader("If-None-Match");
final String etag = (file == null ? 0L : file.lastModified()) + "-" + length; final String etag = (file == null ? 0L : file.lastModified()) + "-" + length;
if (match != null && etag.equals(match)) { if (match != null && etag.equals(match)) {
finish304(); //finish304();
return; //return;
} }
this.contentLength = length; this.contentLength = length;
if (filename != null && !filename.isEmpty() && file != null) { if (filename != null && !filename.isEmpty() && file != null) {
@@ -1006,7 +1006,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
@Override @Override
public void completed(Integer result, ByteBuffer attachment) { public void completed(Integer result, ByteBuffer attachment) {
//(file + "-------------------result: " + result + ", max = " + max + ", count = " + count); //(Thread.currentThread().getName() + "-----------" + file + "-------------------result: " + result + ", max = " + max + ", count = " + count);
if (result < 0 || count >= max) { if (result < 0 || count >= max) {
failed(null, attachment); failed(null, attachment);
return; return;
@@ -1036,7 +1036,11 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
attachment.limit((int) (attachment.position() + max - count)); attachment.limit((int) (attachment.position() + max - count));
} }
attachment.flip(); attachment.flip();
if (attachment.hasRemaining()) {
channel.write(attachment, attachment, this); channel.write(attachment, attachment, this);
} else {
failed(null, attachment);
}
} }
} }