Moved auto-ETag generation out of String encoding block so that ETags are
generated for binary responses. Some minor fixes in auto-ETag gen.
This commit is contained in:
parent
8de915b1bb
commit
c1c7f6af38
1 changed files with 15 additions and 13 deletions
|
@ -349,10 +349,17 @@ public final class ResponseTrans implements Externalizable {
|
||||||
encodingError = true;
|
encodingError = true;
|
||||||
response = buffer.toString ().getBytes ();
|
response = buffer.toString ().getBytes ();
|
||||||
}
|
}
|
||||||
|
buffer = null; // make sure this is done only once, even with more requsts attached
|
||||||
|
} else {
|
||||||
|
response = new byte[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
// if etag is not set, calc MD5 digest and check it
|
// if etag is not set, calc MD5 digest and check it
|
||||||
if (etag == null && lastModified == -1 &&
|
if (etag == null && lastModified == -1 &&
|
||||||
redir == null && error == null) try {
|
redir == null && cache && error == null) try {
|
||||||
digest = MessageDigest.getInstance("MD5");
|
digest = MessageDigest.getInstance("MD5");
|
||||||
|
// if (contentType != null)
|
||||||
|
// digest.update (contentType.getBytes());
|
||||||
byte[] b = digest.digest(response);
|
byte[] b = digest.digest(response);
|
||||||
etag = "\""+new String (Base64.encode(b))+"\"";
|
etag = "\""+new String (Base64.encode(b))+"\"";
|
||||||
if (reqtrans != null && reqtrans.hasETag (etag)) {
|
if (reqtrans != null && reqtrans.hasETag (etag)) {
|
||||||
|
@ -362,11 +369,6 @@ public final class ResponseTrans implements Externalizable {
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
// Etag creation failed for some reason. Ignore.
|
// Etag creation failed for some reason. Ignore.
|
||||||
}
|
}
|
||||||
buffer = null; // make sure this is done only once, even with more requsts attached
|
|
||||||
} else {
|
|
||||||
response = new byte[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
notifyAll ();
|
notifyAll ();
|
||||||
// if there was a problem with the encoding, let the app know
|
// if there was a problem with the encoding, let the app know
|
||||||
if (encodingError)
|
if (encodingError)
|
||||||
|
|
Loading…
Add table
Reference in a new issue