Re: IE SSL cache bug
Re: IE SSL cache bug
- Subject: Re: IE SSL cache bug
- From: Chuck Hill <email@hidden>
- Date: Fri, 18 Apr 2008 21:34:22 -0700
That is a great bug, isn't it! I have enjoyed it many times over the
years. Here is a class that I wrote that seems to fix this. It is
for 5.3, can be trimmed for 5.4. Add this to your project, then add
this method to Application:
public WOResponse createResponseInContext(WOContext context)
{
return new Response();
}
package net.global_village.woextensions;
import com.webobjects.appserver.*;
import com.webobjects.foundation.*;
/**
* Fixes and hacks for WOResponse.
* <p>
* Creates a response configured to use UTF-8 for the
<code>defaultFormValueEncoding()</code>.
* </p>
* <p>
* Prevents disabling client caching for downloads by IE to fix the
bug with IE that causes problems when displaying
* content that cannot be displayed inline in the browswer (pdf
files, for example). This was a known bug in IE 4.0 and
* is reported fixed by MS:
* http://support.microsoft.com/support/kb/articles/Q231/2/96.ASP?LN=EN-US&SD=gn&FR=0&qry=Internet Explorer cannot download&rnk=19&src=DHCS_MSPSS_gn_SRCH&SPR=IE
* "When you try to download a .pdf file from a Web site that uses
the Hypertext Transfer Protocol (HTTP) "Cache-Control =
* 'no-cache'" directive, Internet Explorer may generate the
following error message: Internet Explorer cannot down load
* from the Internet site File_name from Computer_name."
* </p>
*
* @author Copyright (c) 2001-2005 Global Village Consulting, Inc.
All rights reserved.
* This software is published under the terms of the Educational
Community License (ECL) version 1.0,
* a copy of which has been included with this distribution in the
LICENSE.TXT file.
*/
public class Response extends WOResponse
{
public static final String ContentDispositionHeaderKey = "content-
disposition";
public static final String ContentTypeHeaderKey = "content-type";
public static final String DisablePageCachingKey =
"com.webobjects.appserver.Response.DisablePageCaching";
private boolean allowClientCaching = false;
/**
* Creates a response configured to use UTF-8 for the
<code>defaultFormValueEncoding()</code>.
*/
public Response()
{
super();
setContentEncoding(_NSUtilities.UTF8StringEncoding);
}
/**
* Overridden to set allowClientCaching to deal with the IE
download caching bug. Forces all HTML pages returned to
* be UTF-8.
*
* @see
com
.webobjects
.appserver
.WOResponse#_finalizeInContext(com.webobjects.appserver.WOContext)
* @param aContext
* the WOContext the request is being finalized in
*/
public void _finalizeInContext(WOContext aContext)
{
String contentDisposition =
headerForKey(ContentDispositionHeaderKey);
String contentType = headerForKey(ContentTypeHeaderKey);
boolean isAttachment = contentDisposition != null &&
(contentDisposition.indexOf("inline")
> -1 ||
contentDisposition.indexOf("attachment") > -1);
boolean isIE = aContext != null &&
RequestUtilities.isUserAgentInternetExplorer(aContext.request());
boolean isHTML = contentType != null &&
contentType.toLowerCase().indexOf("text/html") > -1;
allowClientCaching = isIE && isAttachment && ! isHTML;
// Force all HTML pages returned to be UTF-8.
if (isHTML)
{
// This controls the display and is also needed to handle
input via forms
setHeader("text/html; charset=UTF-8",
ContentTypeHeaderKey);
}
super._finalizeInContext(aContext);
}
/**
* Overridden to <b>not</b> call super if allowClientCaching is
set.
*
* @see com.webobjects.appserver.WOResponse#disableClientCaching()
*
*/
public void disableClientCaching()
{
if ( ! allowClientCaching) {
super.disableClientCaching();
}
}
/**
* @see #disablePageCaching()
* @return <code>true</code> if disablePageCaching() has been
called for this response
*/
public boolean isPageCachingDisabled()
{
return userInfoForKey(DisablePageCachingKey) != null;
}
/**
* Adds a value for DisablePageCachingKey to this response's
userInfo(). This can be used later
* to flag that this response should not be cached.
*
* @see WOSession#savePage(WOComponent)
* @see #isPageCachingDisabled()
*/
public void disablePageCaching()
{
setUserInfoForKey("dummy value", DisablePageCachingKey);
}
/**
* WO 5.4 API
* Sets the value for key in the user info dictionary.
*
* @param value value to add to userInfo()
* @param key key to add value under
*/
public void setUserInfoForKey(Object value, String key)
{
/** require [valid_value] value != null;
[valid_key] key != null;
**/
NSMutableDictionary newUserInfo = new
NSMutableDictionary(value, key);
if (userInfo() != null)
{
newUserInfo.addEntriesFromDictionary(userInfo());
}
setUserInfo(newUserInfo);
/** ensure [value_set] userInfoForKey(key).equals(value); **/
}
/**
* WO 5.4 API
*
* @param key key to return value from userInfo() for
* @return value from userInfo() for key, or null if not available
*/
public Object userInfoForKey(String key)
{
/** require [valid_key] key != null; **/
return userInfo() != null ? userInfo().objectForKey(key) :
null;
}
}
On Apr 18, 2008, at 9:25 PM, Joe Little wrote:
I have an application that uses SSL for the entire session, which is a
good thing. However, I have some IE users who can't download PDFs and
other documents out of the site. Its related to this Microsoft
knowledge base item:
http://support.microsoft.com/?kbid=323308
More specifically, it would appear that WO is setting the
"Cache-control:no-cache" header. Any hints if this is the default, and
where one would spelunk to find it?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden