Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   //
   //  ========================================================================
   //  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
   //  ------------------------------------------------------------------------
   //  All rights reserved. This program and the accompanying materials
   //  are made available under the terms of the Eclipse Public License v1.0
   //  and Apache License v2.0 which accompanies this distribution.
   //
   //      The Eclipse Public License is available at
  //      http://www.eclipse.org/legal/epl-v10.html
  //
  //      The Apache License v2.0 is available at
  //      http://www.opensource.org/licenses/apache2.0.php
  //
  //  You may elect to redistribute this code under either of these licenses.
  //  ========================================================================
  //
  
  package org.eclipse.jetty.server;
  
  import java.util.Locale;
  
  
Response.

Implements javax.servlet.http.HttpServletResponse from the javax.servlet.http package.

  
  public class Response implements HttpServletResponse
  {
      private static final Logger LOG = Log.getLogger(Response.class);
  
      
      public static final int
          NONE=0,
          STREAM=1,
          WRITER=2;

    
If a header name starts with this string, the header (stripped of the prefix) can be set during include using only setHeader(java.lang.String,java.lang.String) or addHeader(java.lang.String,java.lang.String).
  
      public final static String SET_INCLUDE_HEADER_PREFIX = "org.eclipse.jetty.server.include.";

    
If this string is found within the comment of a cookie added with addCookie(javax.servlet.http.Cookie), then the cookie will be set as HTTP ONLY.
  
      public final static String HTTP_ONLY_COMMENT="__HTTP_ONLY__";
      
      
      /* ------------------------------------------------------------ */
      public static Response getResponse(HttpServletResponse response)
      {
          if (response instanceof Response)
              return (Response)response;
  
          return AbstractHttpConnection.getCurrentConnection().getResponse();
      }
      
      private final AbstractHttpConnection _connection;
      private int _status=;
      private String _reason;
      private Locale _locale;
      private String _mimeType;
      private CachedBuffer _cachedMimeType;
      private String _characterEncoding;
      private boolean _explicitEncoding;
     private String _contentType;
     private volatile int _outputState;
     private PrintWriter _writer;
 
     /* ------------------------------------------------------------ */
    
 
     public Response(AbstractHttpConnection connection)
     {
         =connection;
     }
 
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.ServletResponse#reset()
      */
     protected void recycle()
     {
         =;
         =null;
         =null;
         =null;
         =null;
         =null;
         =false;
         =null;
         =null;
         =;
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.http.HttpServletResponse#addCookie(javax.servlet.http.Cookie)
      */
     public void addCookie(HttpCookie cookie)
     {
         .getResponseFields().addSetCookie(cookie);
     }
     
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.http.HttpServletResponse#addCookie(javax.servlet.http.Cookie)
      */
     public void addCookie(Cookie cookie)
     {
         String comment=cookie.getComment();
         boolean http_only=false;
         
         if (comment!=null)
         {
             int i=comment.indexOf();
             if (i>=0)
             {
                 http_only=true;
                 comment=comment.replace(,"").trim();
                 if (comment.length()==0)
                     comment=null;
             }
         }
                 cookie.getValue(),
                 cookie.getDomain(),
                 cookie.getPath(),
                 cookie.getMaxAge(),
                 comment,
                 cookie.getSecure(),
                 http_only || cookie.isHttpOnly(),
                 cookie.getVersion());
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.http.HttpServletResponse#containsHeader(java.lang.String)
      */
     public boolean containsHeader(String name)
     {
         return .getResponseFields().containsKey(name);
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.http.HttpServletResponse#encodeURL(java.lang.String)
      */
     public String encodeURL(String url)
     {
         final Request request=.getRequest();
         SessionManager sessionManager = request.getSessionManager();
         if (sessionManager==null)
             return url;
         
         HttpURI uri = null;
         if (sessionManager.isCheckingRemoteSessionIdEncoding() && URIUtil.hasScheme(url))
         {
             uri = new HttpURI(url);
             String path = uri.getPath();
             path = (path == null?"":path);
             int port=uri.getPort();
             if (port<0) 
                 port = ..equalsIgnoreCase(uri.getScheme())?443:80;
             if (!request.getServerName().equalsIgnoreCase(uri.getHost()) ||
                 request.getServerPort()!=port ||
                 !path.startsWith(request.getContextPath())) //TODO the root context path is "", with which every non null string starts
                 return url;
         }
         
         String sessionURLPrefix = sessionManager.getSessionIdPathParameterNamePrefix();
         if (sessionURLPrefix==null)
             return url;
 
         if (url==null)
             return null;
         
         // should not encode if cookies in evidence
         if (request.isRequestedSessionIdFromCookie())
         {
             int prefix=url.indexOf(sessionURLPrefix);
             if (prefix!=-1)
             {
                 int suffix=url.indexOf("?",prefix);
                 if (suffix<0)
                     suffix=url.indexOf("#",prefix);
 
                 if (suffix<=prefix)
                     return url.substring(0,prefix);
                 return url.substring(0,prefix)+url.substring(suffix);
             }
             return url;
         }
 
         // get session;
         HttpSession session=request.getSession(false);
 
         // no session
         if (session == null)
             return url;
 
         // invalid session
         if (!sessionManager.isValid(session))
             return url;
 
         String id=sessionManager.getNodeId(session);
 
         if (uri == null)
                 uri = new HttpURI(url);
      
         
         // Already encoded
         int prefix=url.indexOf(sessionURLPrefix);
         if (prefix!=-1)
         {
             int suffix=url.indexOf("?",prefix);
             if (suffix<0)
                 suffix=url.indexOf("#",prefix);
 
             if (suffix<=prefix)
                 return url.substring(0,prefix+sessionURLPrefix.length())+id;
             return url.substring(0,prefix+sessionURLPrefix.length())+id+
                 url.substring(suffix);
         }
 
         // edit the session
         int suffix=url.indexOf('?');
         if (suffix<0)
             suffix=url.indexOf('#');
         if (suffix<0) 
         {          
             return url
                    ((..equalsIgnoreCase(uri.getScheme()) || ..equalsIgnoreCase(uri.getScheme())) && uri.getPath()==null?"/":"") + //if no path, insert the root path
                    sessionURLPrefix+id;
         }
      
         
         return url.substring(0,suffix)+
             ((..equalsIgnoreCase(uri.getScheme()) || ..equalsIgnoreCase(uri.getScheme())) && uri.getPath()==null?"/":"")+ //if no path so insert the root path
             sessionURLPrefix+id+url.substring(suffix);
     }
 
     /* ------------------------------------------------------------ */
    
 
     public String encodeRedirectURL(String url)
     {
         return encodeURL(url);
     }
 
     /* ------------------------------------------------------------ */
     @Deprecated
     public String encodeUrl(String url)
     {
         return encodeURL(url);
     }
 
     /* ------------------------------------------------------------ */
     @Deprecated
     public String encodeRedirectUrl(String url)
     {
         return encodeRedirectURL(url);
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.http.HttpServletResponse#sendError(int, java.lang.String)
      */
     public void sendError(int codeString messagethrows IOException
     {
     	if (.isIncluding())
     		return;
 
         if (isCommitted())
             .warn("Committed before "+code+" "+message);
 
         resetBuffer();
         =null;
         setHeader(.,null);
         setHeader(.,null);
         setHeader(.,null);
         setHeader(.,null);
         setHeader(.,null);
 
         =;
         setStatus(code,message);
 
         if (message==null)
             message=HttpStatus.getMessage(code);
 
         // If we are allowed to have a body
         if (code!= &&
             code!= &&
             code!= &&
             code>=)
         {
             Request request = .getRequest();
 
             ErrorHandler error_handler = null;
             ContextHandler.Context context = request.getContext();
             if (context!=null)
                 error_handler=context.getContextHandler().getErrorHandler();
             if (error_handler==null)
                 error_handler = .getConnector().getServer().getBean(ErrorHandler.class);
             if (error_handler!=null)
             {
                 request.setAttribute(.,new Integer(code));
                 request.setAttribute(.message);
                 request.setAttribute(.request.getRequestURI());
                 request.setAttribute(.,request.getServletName());
                 error_handler.handle(null,.getRequest(),.getRequest(),this );
             }
             else
             {
                 setHeader(."must-revalidate,no-cache,no-store");
                 setContentType(.);
                 ByteArrayISO8859Writer writernew ByteArrayISO8859Writer(2048);
                 if (message != null)
                 {
                     message= StringUtil.replace(message"&""&amp;");
                     message= StringUtil.replace(message"<""&lt;");
                     message= StringUtil.replace(message">""&gt;");
                 }
                 String urirequest.getRequestURI();
                 if (uri!=null)
                 {
                     uri= StringUtil.replace(uri"&""&amp;");
                     uri= StringUtil.replace(uri"<""&lt;");
                     uri= StringUtil.replace(uri">""&gt;");
                 }
 
                 writer.write("<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=ISO-8859-1\"/>\n");
                 writer.write("<title>Error ");
                 writer.write(Integer.toString(code));
                 writer.write(' ');
                 if (message==null)
                     message=HttpStatus.getMessage(code);
                 writer.write(message);
                 writer.write("</title>\n</head>\n<body>\n<h2>HTTP ERROR: ");
                 writer.write(Integer.toString(code));
                 writer.write("</h2>\n<p>Problem accessing ");
                 writer.write(uri);
                 writer.write(". Reason:\n<pre>    ");
                 writer.write(message);
                 writer.write("</pre>");
                 writer.write("</p>\n<hr /><i><small>Powered by Jetty://</small></i>");
 
                 for (int i= 0; i < 20; i++)
                     writer.write("\n                                                ");
                 writer.write("\n</body>\n</html>\n");
 
                 writer.flush();
                 setContentLength(writer.size());
                 writer.writeTo(getOutputStream());
                 writer.destroy();
             }
         }
         else if (code!=)
         {
             =null;
             =null;
             =null;
         }
 
         complete();
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.http.HttpServletResponse#sendError(int)
      */
     public void sendError(int scthrows IOException
     {
         if (sc==102)
             sendProcessing();
         else
             sendError(sc,null);
     }
 
     /* ------------------------------------------------------------ */
     /* Send a 102-Processing response.
      * If the connection is a HTTP connection, the version is 1.1 and the
      * request has a Expect header starting with 102, then a 102 response is
      * sent. This indicates that the request still be processed and real response
      * can still be sent.   This method is called by sendError if it is passed 102.
      * @see javax.servlet.http.HttpServletResponse#sendError(int)
      */
     public void sendProcessing() throws IOException
     {
         if (.isExpecting102Processing() && !isCommitted())
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.http.HttpServletResponse#sendRedirect(java.lang.String)
      */
     public void sendRedirect(String locationthrows IOException
     {
     	if (.isIncluding())
     		return;
 
         if (location==null)
             throw new IllegalArgumentException();
 
         if (!URIUtil.hasScheme(location))
         {
             StringBuilder buf = .getRequest().getRootURL();
             if (location.startsWith("/"))
                 buf.append(location);
             else
             {
                 String path=.getRequest().getRequestURI();
                 String parent=(path.endsWith("/"))?path:URIUtil.parentPath(path);
                 location=URIUtil.addPaths(parent,location);
                 if(location==null)
                     throw new IllegalStateException("path cannot be above root");
                 if (!location.startsWith("/"))
                     buf.append('/');
                 buf.append(location);
             }
 
             location=buf.toString();
             HttpURI uri = new HttpURI(location);
             String path=uri.getDecodedPath();
             String canonical=URIUtil.canonicalPath(path);
             if (canonical==null)
                 throw new IllegalArgumentException();
             if (!canonical.equals(path))
             {
                 buf = .getRequest().getRootURL();
                 buf.append(URIUtil.encodePath(canonical));
                 String param=uri.getParam();
                 if (param!=null)
                 {
                     buf.append(';');
                     buf.append(param);
                 }
                 String query=uri.getQuery();
                 if (query!=null)
                 {
                     buf.append('?');
                     buf.append(query);
                 }
                 String fragment=uri.getFragment();
                 if (fragment!=null)
                 {
                     buf.append('#');
                     buf.append(fragment);
                 }
                 location=buf.toString();
             }
         }
         
         resetBuffer();
         setHeader(.,location);
         complete();
 
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.http.HttpServletResponse#setDateHeader(java.lang.String, long)
      */
     public void setDateHeader(String namelong date)
     {
         if (!.isIncluding())
             .getResponseFields().putDateField(namedate);
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.http.HttpServletResponse#addDateHeader(java.lang.String, long)
      */
     public void addDateHeader(String namelong date)
     {
         if (!.isIncluding())
             .getResponseFields().addDateField(namedate);
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.http.HttpServletResponse#setHeader(java.lang.String, java.lang.String)
      */
     public void setHeader(String nameString value)
     {
         if (..equalsIgnoreCase(name))
             setContentType(value);
         else
         {
             if (.isIncluding())
             {
                 if (name.startsWith())
                     name=name.substring(.length());
                 else
                     return;
             }
             .getResponseFields().put(namevalue);
             if (..equalsIgnoreCase(name))
             {
                 if (value==null)
                     ..setContentLength(-1);
                 else
                     ..setContentLength(Long.parseLong(value));
             }
         }
     }
 
 
     /* ------------------------------------------------------------ */
     public Collection<StringgetHeaderNames()
     {
         final HttpFields fields=.getResponseFields();
         return fields.getFieldNamesCollection();
     }
     
     /* ------------------------------------------------------------ */
     /*
      */
     public String getHeader(String name)
     {
         return .getResponseFields().getStringField(name);
     }
 
     /* ------------------------------------------------------------ */
     /*
      */
     public Collection<StringgetHeaders(String name)
     {
         final HttpFields fields=.getResponseFields();
         Collection<Stringi = fields.getValuesCollection(name);
         if (i==null)
             return .;
         return i;
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.http.HttpServletResponse#addHeader(java.lang.String, java.lang.String)
      */
     public void addHeader(String nameString value)
     {
         if (.isIncluding())
         {
             if (name.startsWith())
                 name=name.substring(.length());
             else
                 return;
         }
 
         .getResponseFields().add(namevalue);
         if (..equalsIgnoreCase(name))
             ..setContentLength(Long.parseLong(value));
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.http.HttpServletResponse#setIntHeader(java.lang.String, int)
      */
     public void setIntHeader(String nameint value)
     {
         if (!.isIncluding())
         {
             .getResponseFields().putLongField(namevalue);
             if (..equalsIgnoreCase(name))
                 ..setContentLength(value);
         }
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.http.HttpServletResponse#addIntHeader(java.lang.String, int)
      */
     public void addIntHeader(String nameint value)
     {
         if (!.isIncluding())
         {
             .getResponseFields().addLongField(namevalue);
             if (..equalsIgnoreCase(name))
                 ..setContentLength(value);
         }
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.http.HttpServletResponse#setStatus(int)
      */
     public void setStatus(int sc)
     {
         setStatus(sc,null);
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.http.HttpServletResponse#setStatus(int, java.lang.String)
      */
     public void setStatus(int scString sm)
     {
         if (sc<=0)
             throw new IllegalArgumentException();
         if (!.isIncluding())
         {
             =sc;
             =sm;
         }
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.ServletResponse#getCharacterEncoding()
      */
     public String getCharacterEncoding()
     {
         if (==null)
             =.;
         return ;
     }
     
     /* ------------------------------------------------------------ */
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.ServletResponse#getContentType()
      */
     public String getContentType()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.ServletResponse#getOutputStream()
      */
     public ServletOutputStream getOutputStream() throws IOException
     {
         if (!= && !=)
             throw new IllegalStateException("WRITER");
 
         ServletOutputStream out = .getOutputStream();
         =;
         return out;
     }
 
     /* ------------------------------------------------------------ */
     public boolean isWriting()
     {
         return ==;
     }
 
     /* ------------------------------------------------------------ */
     public boolean isOutputing()
     {
         return !=;
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.ServletResponse#getWriter()
      */
     public PrintWriter getWriter() throws IOException
     {
         if (!= && !=)
             throw new IllegalStateException("STREAM");
 
         /* if there is no writer yet */
         if (==null)
         {
             /* get encoding from Content-Type header */
             String encoding = ;
 
             if (encoding==null)
             {
                 /* implementation of educated defaults */
                 if( != null)
                     encoding = MimeTypes.getCharsetFromContentType();
 
                 if (encoding==null)
                     encoding = .;
 
                 setCharacterEncoding(encoding);
             }
 
             /* construct Writer using correct encoding */
              = .getPrintWriter(encoding);
         }
         =;
         return ;
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.ServletResponse#setCharacterEncoding(java.lang.String)
      */
     public void setCharacterEncoding(String encoding)
     {
     	if (.isIncluding())
     		return;
 
         if (this.==0 && !isCommitted())
         {
             =true;
 
             if (encoding==null)
             {
                 // Clear any encoding.
                 if (!=null)
                 {
                     =null;
                     if (!=null)
                         =.toString();
                     else if (!=null)
                         =;
                     else
                         =null;
 
                     if (==null)
                         .getResponseFields().remove(.);
                     else
                         .getResponseFields().put(.,);
                 }
             }
             else
             {
                 // No, so just add this one to the mimetype
                 =encoding;
                 if (!=null)
                 {
                     int i0=.indexOf(';');
                     if (i0<0)
                     {
                         =null;
                         if(!=null)
                         {
                             CachedBuffer content_type = .getAssociate();
                             if (content_type!=null)
                             {
                                 =content_type.toString();
                                 .getResponseFields().put(.,content_type);
                             }
                         }
 
                         if (==null)
                         {
                              = +";charset="+QuotedStringTokenizer.quoteIfNeeded(,";= ");
                             .getResponseFields().put(.,);
                         }
                     }
                     else
                     {
                         int i1=.indexOf("charset=",i0);
                         if (i1<0)
                         {
                              = +";charset="+QuotedStringTokenizer.quoteIfNeeded(,";= ");
                         }
                         else
                         {
                             int i8=i1+8;
                             int i2=.indexOf(" ",i8);
                             if (i2<0)
                                 =.substring(0,i8)+QuotedStringTokenizer.quoteIfNeeded(,";= ");
                             else
                                 =.substring(0,i8)+QuotedStringTokenizer.quoteIfNeeded(,";= ")+.substring(i2);
                         }
                         .getResponseFields().put(.,);
                     }
                 }
             }
         }
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.ServletResponse#setContentLength(int)
      */
     public void setContentLength(int len)
     {
         // Protect from setting after committed as default handling
         // of a servlet HEAD request ALWAYS sets _content length, even
         // if the getHandling committed the response!
         if (isCommitted() || .isIncluding())
             return;
         if (len>0)
         {
             if (..isAllContentWritten())
             {
                 if (==)
                     .close();
                 else if (==)
                 {
                     try
                     {
                         getOutputStream().close();
                     }
                     catch(IOException e)
                     {
                         throw new RuntimeException(e);
                     }
                 }
             }
         }
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.ServletResponse#setContentLength(int)
      */
     public void setLongContentLength(long len)
     {
         // Protect from setting after committed as default handling
         // of a servlet HEAD request ALWAYS sets _content length, even
         // if the getHandling committed the response!
         if (isCommitted() || .isIncluding())
         	return;
     }
 
     /* ------------------------------------------------------------ */
     /*
      * @see javax.servlet.ServletResponse#setContentType(java.lang.String)
      */
     public void setContentType(String contentType)
     {
         if (isCommitted() || .isIncluding())
             return;
 
         // Yes this method is horribly complex.... but there are lots of special cases and
         // as this method is called on every request, it is worth trying to save string creation.
         //
 
         if (contentType==null)
         {
             if (==null)
                 =null;
             =null;
             =null;
             =null;
         }
         else
         {
             // Look for encoding in contentType
             int i0=contentType.indexOf(';');
 
             if (i0>0)
             {
                 // we have content type parameters
 
                 // Extract params off mimetype
                 =contentType.substring(0,i0).trim();
                 =..get();
 
                 // Look for charset
                 int i1=contentType.indexOf("charset=",i0+1);
                 if (i1>=0)
                 {
                     =true;
                     int i8=i1+8;
                     int i2 = contentType.indexOf(' ',i8);
 
                     if (==)
                     {
                         // strip the charset and ignore;
                         if ((i1==i0+1 && i2<0) || (i1==i0+2 && i2<0 && contentType.charAt(i0+1)==' '))
                         {
                             if (!=null)
                             {
                                 CachedBuffer content_type = .getAssociate();
                                 if (content_type!=null)
                                 {
                                     =content_type.toString();
                                     .getResponseFields().put(.,content_type);
                                 }
                                 else
                                 {
                                     =+";charset="+;
                                     .getResponseFields().put(.,);
                                 }
                             }
                             else
                             {
                                 =+";charset="+;
                                 .getResponseFields().put(.,);
                             }
                         }
                         else if (i2<0)
                         {
                             =contentType.substring(0,i1)+";charset="+QuotedStringTokenizer.quoteIfNeeded(,";= ");
                             .getResponseFields().put(.,);
                         }
                         else
                         {
                             =contentType.substring(0,i1)+contentType.substring(i2)+";charset="+QuotedStringTokenizer.quoteIfNeeded(,";= ");
                             .getResponseFields().put(.,);
                         }
                     }
                     else if ((i1==i0+1 && i2<0) || (i1==i0+2 && i2<0 && contentType.charAt(i0+1)==' '))
                     {
                         // The params are just the char encoding
                         =..get();
                          = QuotedStringTokenizer.unquote(contentType.substring(i8));
 
                         if (!=null)
                         {
                             CachedBuffer content_type = .getAssociate();
                             if (content_type!=null)
                             {
                                 =content_type.toString();
                                 .getResponseFields().put(.,content_type);
                             }
                             else
                             {
                                 =contentType;
                                 .getResponseFields().put(.,);
                             }
                         }
                         else
                         {
                             =contentType;
                             .getResponseFields().put(.,);
                         }
                     }
                     else if (i2>0)
                     {
                          = QuotedStringTokenizer.unquote(contentType.substring(i8,i2));
                         =contentType;
                         .getResponseFields().put(.,);
                     }
                     else
                     {
                          = QuotedStringTokenizer.unquote(contentType.substring(i8));
                         =contentType;
                         .getResponseFields().put(.,);
                     }
                 }
                 else // No encoding in the params.
                 {
                     =null;
                     ===null?contentType:contentType+";charset="+QuotedStringTokenizer.quoteIfNeeded(,";= ");
                     .getResponseFields().put(.,);
                 }
             }
             else // No params at all
             {
                 =contentType;
                 =..get();
 
                 if (!=null)
                 {
                     if (!=null)
                     {
                         CachedBuffer content_type = .getAssociate();
                         if (content_type!=null)
                        {
                            =content_type.toString();
                            .getResponseFields().put(.,content_type);
                        }
                        else
                        {
                            =+";charset="+QuotedStringTokenizer.quoteIfNeeded(,";= ");
                            .getResponseFields().put(.,);
                        }
                    }
                    else
                    {
                        =contentType+";charset="+QuotedStringTokenizer.quoteIfNeeded(,";= ");
                        .getResponseFields().put(.,);
                    }
                }
                else if (!=null)
                {
                    =.toString();
                }
                else
                {
                    =contentType;
                }
            }
        }
    }
    /* ------------------------------------------------------------ */
    /*
     * @see javax.servlet.ServletResponse#setBufferSize(int)
     */
    public void setBufferSize(int size)