Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  //
  //  ========================================================================
  //  Copyright (c) 1995-2012 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;
 
 
 
 
 /* ------------------------------------------------------------ */
Blocking Server HTTP Connection
 
 {
     private static final Logger LOG = Log.getLogger(BlockingHttpConnection.class);
 
     public BlockingHttpConnection(Connector connectorEndPoint endpointServer server)
     {
         super(connector,endpoint,server);
     }
 
     public BlockingHttpConnection(Connector connectorEndPoint endpointServer serverParser parserGenerator generatorRequest request)
     {
         super(connector,endpoint,server,parser,generator,request);
     }
 
     @Override
     protected void handleRequest() throws IOException
     {
         super.handleRequest();
     }
 
     public Connection handle() throws IOException
     {
         Connection connection = this;
 
         try
         {
             setCurrentConnection(this);
 
             // do while the endpoint is open
             // AND the connection has not changed
             while (.isOpen() && connection==this)
             {
                 try
                 {
                     // If we are not ended then parse available
                     if (!.isComplete() && !.isInputShutdown())
                         .parseAvailable();
 
                     // Do we have more generating to do?
                     // Loop here because some writes may take multiple steps and
                     // we need to flush them all before potentially blocking in the
                     // next loop.
                     if (.isCommitted() && !.isComplete() && !.isOutputShutdown())
                         .flushBuffer();
 
                     // Flush buffers
                     .flush();
                 }
                 catch (HttpException e)
                 {
                     if (.isDebugEnabled())
                     {
                         .debug("uri="+);
                         .debug("fields="+);
                         .debug(e);
                     }
                     .sendError(e.getStatus(), e.getReason(), nulltrue);
                     .reset();
                     .shutdownOutput();
                 }
                 finally
                 {
                     //  Is this request/response round complete and are fully flushed?
                     if (.isComplete() && .isComplete())
                    {
                        // Reset the parser/generator
                        reset();
                        // look for a switched connection instance?
                        if (.getStatus()==.)
                        {
                            Connection switched=(Connection).getAttribute("org.eclipse.jetty.io.Connection");
                            if (switched!=null)
                                connection=switched;
                        }
                        // TODO Is this required?
                        if (!.isPersistent() && !.isOutputShutdown())
                        {
                            .warn("Safety net oshut!!! Please open a bugzilla");
                            .shutdownOutput();
                        }
                    }
                    
                    // If we don't have a committed response and we are not suspended
                    if (.isInputShutdown() && .isIdle() && !.getAsyncContinuation().isSuspended())
                    {
                        // then no more can happen, so close.
                        .close();
                    }
                }
            }
            return connection;
        }
        finally
        {
            setCurrentConnection(null);
            .returnBuffers();
            .returnBuffers();
        }
    }
New to GrepCode? Check out our FAQ X