1
//========================================================================
2
//$Id: MsieSslRule.java 966 2008-04-17 13:53:44Z gregw $
3
//Copyright 2004-2005 Mort Bay Consulting Pty. Ltd.
4
//------------------------------------------------------------------------
5
//Licensed under the Apache License, Version 2.0 (the "License");
6
//you may not use this file except in compliance with the License.
7
//You may obtain a copy of the License at
8
//http://www.apache.org/licenses/LICENSE-2.0
9
//Unless required by applicable law or agreed to in writing, software
10
//distributed under the License is distributed on an "AS IS" BASIS,
11
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//See the License for the specific language governing permissions and
13
//limitations under the License.
14
//========================================================================
15
package org.mortbay.jetty.handler.rewrite;
17
import java.io.IOException;
19
import javax.servlet.http.HttpServletRequest;
20
import javax.servlet.http.HttpServletResponse;
22
import org.mortbay.jetty.HttpHeaderValues;
23
import org.mortbay.jetty.HttpHeaders;
24
import org.mortbay.util.StringMap;
27
* MSIE (Microsoft Internet Explorer) SSL Rule.
28
* Disable keep alive for SSL from IE5 or IE6 on Windows 2000.
33
public class MsieSslRule extends Rule
35
private static final int IEv5 = '5';
36
private static final int IEv6 = '6';
37
private static StringMap __IE6_BadOS = new StringMap();
39
__IE6_BadOS.put("NT 5.01", Boolean.TRUE);
40
__IE6_BadOS.put("NT 5.0",Boolean.TRUE);
41
__IE6_BadOS.put("NT 4.0",Boolean.TRUE);
42
__IE6_BadOS.put("98",Boolean.TRUE);
43
__IE6_BadOS.put("98; Win 9x 4.90",Boolean.TRUE);
44
__IE6_BadOS.put("95",Boolean.TRUE);
45
__IE6_BadOS.put("CE",Boolean.TRUE);
54
public String matchAndApply(String target, HttpServletRequest request, HttpServletResponse response) throws IOException
56
if (request.isSecure())
58
String user_agent = request.getHeader(HttpHeaders.USER_AGENT);
62
int msie=user_agent.indexOf("MSIE");
63
if (msie>0 && user_agent.length()-msie>5)
65
// Get Internet Explorer Version
66
int ieVersion = user_agent.charAt(msie+5);
70
response.setHeader(HttpHeaders.CONNECTION, HttpHeaderValues.CLOSE);
76
int windows = user_agent.indexOf("Windows",msie+5);
79
int end=user_agent.indexOf(')',windows+8);
80
if(end<0 || __IE6_BadOS.getEntry(user_agent,windows+8,end-windows-8)!=null)
82
response.setHeader(HttpHeaders.CONNECTION, HttpHeaderValues.CLOSE);