Package com.sun.grizzly.tcp

Examples of com.sun.grizzly.tcp.Response


        Object ptask = ((ClbProxyProtocolInfo) protocolInfo).object;

        ProxyRequestHandler task = null;
        Endpoint endpoint = null;
        Request request = null;
        Response response = null;       
        proxy.setSelectorThread(((ClbProxyProtocolInfo) protocolInfo).selectorThread);
      
        if (ptask != null) {
            task = (ProxyRequestHandler) ptask;
            response = task.getResponse();
            request = task.getRequest();

            if (response.getStatus() != 200) {
                if (response.getStatus() == -1) {
                    if (_logger.isLoggable(Level.FINEST)){
                        _logger.log(Level.FINEST, "http-maximum-overload");
                    }
                    doOverloadAction(response);
                /* maximum overload condition
                 * sleeping keeps the thread occupied,
                 * we close the connection and release the task later
                 */
                } else {
                    _logger.log(Level.SEVERE,
                            "clb.proxy.http.handler_error_response");
                    response.setHeader(LoadBalancerProxyConstants.HTTP_CONNECTION_HEADER,
                            LoadBalancerProxyConstants.HTTP_CONNECTION_CLOSE_VALUE);
                    if (task.isSecure()) {
                        sendSecureResponse(request, response);
                    } else {
                        sendResponse(request, response);
View Full Code Here


        inputStream = secure ? new SSLByteBufferInputStream()
        : new ByteBufferInputStream();
       
        inputBuffer.setInputStream(inputStream);
        request.setInputBuffer(inputBuffer);
        response = new Response();
        outputBuffer = secure ? new SSLOutputBuffer(response,
                LoadBalancerProxyConstants.DEFAULT_HTTP_HEADER_BUFFER_SIZE,
                false):
            new SocketChannelOutputBuffer
                (response,
View Full Code Here

        throws IOException {
        if( ep.isLogTimeEnabled() )
            ep.setLong( MsgContext.TIMER_PRE_REQUEST, System.currentTimeMillis());
       
        Request req=ep.getRequest();
        Response res=req.getResponse();

        if( log.isLoggable(Level.FINEST) )
            log.finest( "Invoke " + req + " " + res + " " + req.requestURI().toString());
       
        res.setNote( epNote, ep );
        ep.setStatus( MsgContext.JK_STATUS_HEAD );
        RequestInfo rp = req.getRequestProcessor();
        rp.setStage(Constants.STAGE_SERVICE);
        try {
            adapter.service( req, res );
        } catch( Exception ex ) {
            log.log(Level.INFO, "Error servicing request " + req,ex);
        }
        if(ep.getStatus() != MsgContext.JK_STATUS_CLOSED) {
            res.finish();
        }

        req.recycle();
        req.updateCounters();
        res.recycle();
        ep.recycle();
        if( ep.getStatus() == MsgContext.JK_STATUS_ERROR ) {
            return ERROR;
        }
        ep.setStatus( MsgContext.JK_STATUS_NEW );
View Full Code Here

    /** The high level request object associated with this context
     */
    public final void setRequest( Request req ) {
        this.req=req;
        req.setInputBuffer(jkIS);
        Response res = req.getResponse();
        res.setOutputBuffer(jkIS);
        res.setHook(this);
    }
View Full Code Here

    public void action(ActionCode actionCode, Object param) {
        if( actionCode==ActionCode.ACTION_COMMIT ) {
            if( log.isLoggable(Level.FINEST) ) {
                log.finest("COMMIT " );
            }
            Response res=(Response)param;

            ifres.isCommitted() ) {
                if( log.isLoggable(Level.FINEST) ) {
                    log.finest("Response already committed " );
                }
            } else {
                try {
                    jkIS.appendHead( res );
                } catch(IOException iex) {
                    log.log(Level.WARNING, "Unable to send headers",iex);
                    setStatus(JK_STATUS_ERROR);
                }
            }
        } else if( actionCode==ActionCode.ACTION_RESET ) {
            if( log.isLoggable(Level.FINEST) ) {
                log.finest("RESET " );
            }
        } else if( actionCode==ActionCode.ACTION_CLIENT_FLUSH ) {
            if( log.isLoggable(Level.FINEST) ) {
                log.finest("CLIENT_FLUSH " );
            }
            Response res = (Response)param;
            if(!res.isCommitted()) {
    action(ActionCode.ACTION_COMMIT, res);
      }
            try {
                source.flush( null, this );
            } catch(IOException iex) {
                // This is logged elsewhere, so debug only here
                log.log(Level.FINEST, "Error during flush",iex);
                res.setErrorException(iex);
                setStatus(JK_STATUS_ERROR);
            }
           
        } else if( actionCode==ActionCode.ACTION_CLOSE ) {
            if( log.isLoggable(Level.FINEST) ) {
                log.finest("CLOSE " );
            }
            Response res=(Response)param;
            if( getStatus()== JK_STATUS_CLOSED || getStatus() == JK_STATUS_ERROR) {
                // Double close - it may happen with forward
                if( log.isLoggable(Level.FINEST) ) {
                    log.finest("Double CLOSE - forward ? " +
                        res.getRequest().requestURI() );
                }
                return;
            }
                
            if( !res.isCommitted() )
                this.action( ActionCode.ACTION_COMMIT, param );
            try {           
                jkIS.endMessage();
            } catch(IOException iex) {
                log.log(Level.FINEST, "Error sending end packet",iex);
                setStatus(JK_STATUS_ERROR);
            }
            if(getStatus() != JK_STATUS_ERROR) {
                setStatus(JK_STATUS_CLOSED );
            }

            if( logTime.isLoggable(Level.FINEST) )
                logTime(res.getRequest(), res);
        } else if( actionCode==ActionCode.ACTION_REQ_SSL_ATTRIBUTE ) {
            Request req=(Request)param;

            // Extract SSL certificate information (if requested)
            MessageBytes certString = (MessageBytes)req.getNote(WorkerEnv.SSL_CERT_NOTE);
View Full Code Here

                }
            } catch( Exception ex ) {
                /* If we are here it is because we have a bad header or something like that */
                log.log(Level.SEVERE, "Error decoding request ", ex );
                msg.dump( "Incomming message");
                Response res=ep.getRequest().getResponse();
                if ( res==null ) {
                    res=new Response();
                    ep.getRequest().setResponse(res);
                }
                res.setMessage("Bad Request");
                res.setStatus(400);
                return ERROR;

            }

            if( requiredSecret != null ) {
View Full Code Here

    private Request checkRequest(MsgContext ep) {
        Request req=ep.getRequest();
        if( req==null ) {
            req=new Request();
            Response res=new Response();
            req.setResponse(res);
            ep.setRequest( req );
            if( registerRequests ) {
                synchronized(lock) {
                    ep.getSource().registerRequest(req, ep, count++);
View Full Code Here

    public boolean doFilter( AsyncExecutor asyncExecutor )
    {
        ProcessorTask task = (ProcessorTask) asyncExecutor.getProcessorTask();

        Response response = task.getRequest().getResponse();

        if ( task.getRequest().requestURI().toString().endsWith( GRAPHML_SUFFIX ) )
        {
            response.addHeader( CONTENT_DISPOSITION, ATTACHMENT_DISPOSITION );
        }

        // Pass execution onwards
        task.invokeAdapter();
View Full Code Here

TOP

Related Classes of com.sun.grizzly.tcp.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.