KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mortbay > http > handler > MsieSslHandler


1 // ========================================================================
2
// $Id: MsieSslHandler.java,v 1.3 2005/08/13 00:01:26 gregwilkins Exp $
3
// Copyright 2003-2004 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

16
17 package org.mortbay.http.handler;
18
19 import java.io.IOException JavaDoc;
20
21 import org.apache.commons.logging.Log;
22 import org.mortbay.log.LogFactory;
23 import org.mortbay.http.HttpException;
24 import org.mortbay.http.HttpFields;
25 import org.mortbay.http.HttpRequest;
26 import org.mortbay.http.HttpResponse;
27
28 /**
29  * Handler to force MSIE SSL connections to not be persistent to
30  * work around MSIE5 bug.
31  *
32  * @author gregw
33  * @author chris haynes
34  *
35  */

36 public class MsieSslHandler extends AbstractHttpHandler
37 {
38     private static Log log = LogFactory.getLog(MsieSslHandler.class);
39     
40     private String JavaDoc userAgentSubString="MSIE 5";
41     
42     /*
43      * @see org.mortbay.http.HttpHandler#handle(java.lang.String, java.lang.String, org.mortbay.http.HttpRequest, org.mortbay.http.HttpResponse)
44      */

45     public void handle(
46         String JavaDoc pathInContext,
47         String JavaDoc pathParams,
48         HttpRequest request,
49         HttpResponse response)
50         throws HttpException, IOException JavaDoc
51     {
52         String JavaDoc userAgent = request.getField(HttpFields.__UserAgent);
53         
54         if(userAgent != null &&
55            userAgent.indexOf( userAgentSubString)>=0 &&
56            HttpRequest.__SSL_SCHEME.equalsIgnoreCase(request.getScheme()))
57         {
58             if (log.isDebugEnabled())
59                 log.debug("Force close");
60             response.setField(HttpFields.__Connection, HttpFields.__Close);
61             request.getHttpConnection().forceClose();
62         }
63     }
64     
65     /**
66      * @return The substring to match against the User-Agent field
67      */

68     public String JavaDoc getUserAgentSubString()
69     {
70         return userAgentSubString;
71     }
72
73     /**
74      * @param string The substring to match against the User-Agent field
75      */

76     public void setUserAgentSubString(String JavaDoc string)
77     {
78         userAgentSubString= string;
79     }
80
81 }
82
Popular Tags