Downloading Artifacts over HTTPS using Internet Explorer

My configuration

TeamCity 4.0.1 J2EE package
Tomcat 6.0.18 container
Windows 2003 Server

Tomcat is set to redirect all traffic to HTTPS, and is using a self signed certificate.

Using Internet Explorer 7, I get the following error when attempting to download a war file built on the server.  Firefox works fine.


---------------------------
Windows Internet Explorer
---------------------------
Internet Explorer cannot download <package>.war from <server>.



Internet Explorer was not able to open this Internet site.  The requested site is either unavailable or cannot be found.  Please try again later.
---------------------------
OK  
---------------------------

My research indicates this is an issue with the no-cache header, but I don't know how to disable this for all of Tomcat

9 comments
Comment actions Permalink

To solve this problem, I wrote a Java EE Filter to force the Pragma and Cache-control off both before and after the filter chain.

Then modified the application web.xml to have the filter last.

This filter could be improved to look for only secure connections etc.







public class KillCacheFilter implements Filter
{
    @Override
    public void doFilter(ServletRequest arg0, ServletResponse arg1,
            FilterChain arg2) throws IOException, ServletException
    {
       
        HttpServletResponse httpResp = (HttpServletResponse)arg1;

       
        httpResp.setHeader("Pragma", "");
        httpResp.setHeader("Cache-control", "");
       
       
       
        arg2.doFilter(arg0, arg1);
       
       
        httpResp.setHeader("Pragma", "");
        httpResp.setHeader("Cache-control", "");
       
       
       
       
    }

    @Override
    public void destroy()
    {       
    }

    @Override
    public void init(FilterConfig arg0) throws ServletException
    {   
    }

}

0
Comment actions Permalink

Could you please describe what URLs cause this problem?

0
Comment actions Permalink

https://<server>/repository/download/bt5/29:id/<filename>.war

Is an example.  Basically anything that you right clicked, and selected save as, for.
After I added this filter, I also had to add mime-type information to war/jar extentions to prevent IE from saving them to .zip files.  Basically specifiying them as application octet streams makes IE retain the extension becaucse it can't automatically determine the extensions.

-Scott

0
Comment actions Permalink

For these urls cache is enabled. TeamCity should not send "nocache" headers when you download artifacts. Are you sure there is no proxy between TeamCity and browser? How is your TeamCity server installed? Do you use Tomcat bundled with TeamCity or you installed war file? Is there an Apache or IIS server intercepting requests to TeamCity?

0
Comment actions Permalink

TeamCity is installed as a JavaEE WAR, to my own setup instance of Tomcat 6.0.18. After deployment I moved the deployment from TeamCity to ROOT so it would be served at the base of the server.

IIS is turned off, and there should be no proxy between the client and the server.  I can't be sure, as IT may have setup something in that VLAN that is doing something unexpected.  I will also follow up with them.  I observed the headers using Firefox and Firebug to expose the headers after the HTTPs tunnel.

0
Comment actions Permalink

I cannot reproduce this problem. I tried to download artifacts using IE6 by HTTPS and got no errors at all. To be sure I installed Fiddler2 proxy (this version supports HTTPS proxy) and dumped response sent by TeamCity server:

HTTP/1.1 206 Partial Content
Date: Tue, 10 Feb 2009 10:22:29 GMT
Expires: Tue, 10 Feb 2009 11:22:29 GMT
Cache-Control: max-age=3600
Last-Modified: Tue, 10 Feb 2009 09:39:15 GMT
Accept-Ranges: bytes
ETag: "84b9d33a7d7e9a0c039c49e9a3fb2f7e"
Content-Disposition: inline; filename="classes.zip";
Content-Range: bytes 1818616-14389865/14389866
Content-Length: 12571250
Keep-Alive: timeout=15, max=95
Connection: Keep-Alive
Content-Type: application/zip

As you can see we specifically enable cache for one hour when browser downloads artifacts. Could you please try to install Fiddler2 proxy and see what headers are sent in your case?

0
Comment actions Permalink

This first header capture represents the broken download, with the filter I wrote turned off.

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: max-age=3600
Expires: Tue, 10 Feb 2009 20:23:58 GMT
Set-Cookie: RememberMe=-448235702^2#1940758371170667935; Expires=Tue, 24-Feb-2009 19:23:58 GMT; Path=/
Last-Modified: Mon, 09 Feb 2009 16:37:17 GMT
Accept-Ranges: bytes
ETag: "47874ea8de0d724a95bfd983b0039e8c"
Content-Disposition: inline; filename="DiagnosticPanel.war";
Content-Type: application/octet-stream
Content-Length: 18271671
Date: Tue, 10 Feb 2009 19:23:58 GMT



 



This is with the filter enabled, and being able to successfully download files in IE over HTTPS


HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Pragma:
Cache-Control: max-age=3600
Expires: Tue, 10 Feb 2009 20:27:22 GMT
Set-Cookie: RememberMe=-448235702^2#1940758371170667935; Expires=Tue, 24-Feb-2009 19:27:22 GMT; Path=/
Last-Modified: Mon, 09 Feb 2009 16:37:17 GMT
Accept-Ranges: bytes
ETag: "47874ea8de0d724a95bfd983b0039e8c"
Content-Disposition: inline; filename="DiagnosticPanel.war";
Content-Type: application/octet-stream
Content-Length: 18271671
Date: Tue, 10 Feb 2009 19:27:22 GMT



 





The only difference is the "Pragma" header is modified.  IE7 was used and tested.

0
Comment actions Permalink

I still can't find when TeamCity can set Pragma header. Even if it could do so, it will set other headers too, like Expires set to 1970 year and Cache-Control. So right now I do not see what to fix here, because I cannot reproduce this problem at our side.

Is it possible that servlet container configuration was modified to disable cache in browsers?

0

Please sign in to leave a comment.