mcardle 2005/12/22 03:24:06 CET
Modified files:
src/net/sf/j2ep/responsehandlers ResponseHandlerBase.java
Log:
* fixes bad contentLength for issue http://www.jahia.org/jira/browse/JAHIA-597
Revision Changes Path
1.18 +33 -8
esi_server/src/net/sf/j2ep/responsehandlers/ResponseHandlerBase.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/esi_server/src/net/sf/j2ep/responsehandlers/ResponseHandlerBase.java.diff?r1=1.17&r2=1.18&f=h
Index: ResponseHandlerBase.java
===================================================================
RCS file:
/home/cvs/repository/esi_server/src/net/sf/j2ep/responsehandlers/ResponseHandlerBase.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ResponseHandlerBase.java 14 Dec 2005 16:44:11 -0000 1.17
+++ ResponseHandlerBase.java 22 Dec 2005 02:24:05 -0000 1.18
@@ -213,6 +213,9 @@
OutputStream clientResponseStream = clientResponse.getOutputStream();
+ //reset content-length header previously set by
copyHeadersFromServerResponseToClientResponse()
+ clientResponse.setContentLength(cachedByteContent.length);
+
if (cachedByteContent==null) {
log.error("sendStreamToClientFromCache : cachedByteContent is
NULL. so not sending anything");
}
@@ -241,17 +244,38 @@
boolean
isRedirect) {
Header[] headers = methodToServer.getResponseHeaders();
+ boolean lastmodified = false;
+ boolean expires = false;
+ boolean fromEsiEnabledResponse = false;
+
for (int i=0; i < headers.length; i++) {
Header header = headers[i];
String name = header.getName();
String val = header.getValue(); //TODO: need to consider the
case when more than one value is possible for one header i.e. using
HeaderElement[] getValues()
- boolean contentLength =
false;//name.equalsIgnoreCase("content-length"); //Why does it ignore
contentLength?
- boolean connection = name.equalsIgnoreCase("connection");
- boolean setcookie = name.equalsIgnoreCase("set-cookie");
- boolean location = name.equalsIgnoreCase("location");
- boolean referer = name.equalsIgnoreCase("referer");
- boolean transferEncodingChunked =
name.equalsIgnoreCase("Transfer-Encoding")
- && val.toLowerCase().indexOf("chunked")!=-1;
+
+ boolean connection = false;
+ boolean setcookie = false;
+ boolean location=false;
+ boolean referer=false;
+ boolean transferEncodingChunked=false;
+
+ if (name.equalsIgnoreCase("connection"))
+ connection=true;
+ else if (name.equalsIgnoreCase("set-cookie"))
+ setcookie=true;
+ else if (name.equalsIgnoreCase("location"))
+ location=true;
+ else if (name.equalsIgnoreCase("referer"))
+ referer=true;
+ else if (name.equalsIgnoreCase("Transfer-Encoding")
+ && val.toLowerCase().indexOf("chunked")!=-1)
+ transferEncodingChunked=true;
+ else if (name.equalsIgnoreCase("Last-Modified"))
+ lastmodified=true;
+ else if (name.equalsIgnoreCase("Expires"))
+ expires=true;
+ else if
(name.equalsIgnoreCase(EsiConst.SURROGATE_CONTROL_HEADER))
+ fromEsiEnabledResponse=true;
if (log.isDebugEnabled()) log.debug("Detected Server Response
header : "+name+":"+val);
@@ -274,7 +298,8 @@
val = uri.toString(""); //"" makes sure it doesn't reencode
the URL
}
- if (!contentLength && !connection && !transferEncodingChunked) {
+ if (!connection
+ && !transferEncodingChunked) {
//optionally ignore Set-Cookie header
if (setcookie && ignoreCookies) {
log.info("Ignored Set-Cookie header because this is a
response returned from Cache. Header:"+header);