Examples of HttpConnection


Examples of org.apache.http.HttpConnection

        // based on testChunkedContent which is known to return true
        // the difference is in the mock connection passed here
        HttpResponse response =
            createResponse(HttpVersion.HTTP_1_1, 200, "OK", true, -1);

        HttpConnection mockonn = new MockConnection(true, true);
        context.setAttribute(HttpExecutionContext.HTTP_CONNECTION, mockonn);
        assertTrue("stale connection should not be detected",
                    reuseStrategy.keepAlive(response, context));
    }
View Full Code Here

Examples of org.apache.http.HttpConnection

       
        Iterator<HttpConnection> connectionIter =
            connectionToTimes.keySet().iterator();
       
        while (connectionIter.hasNext()) {
            HttpConnection conn = connectionIter.next();
            TimeValues times = connectionToTimes.get(conn);
            long connectionTime = times.timeAdded;
            if (connectionTime <= idleTimeout) {
                if (log.isDebugEnabled()) {
                    log.debug("Closing connection, connection time: "  + connectionTime);
                }
                connectionIter.remove();
                try {
                    conn.close();
                } catch (IOException ex) {
                    log.debug("I/O error closing connection", ex);
                }
            }
        }
View Full Code Here

Examples of org.apache.http.HttpConnection

       
        Iterator<HttpConnection> connectionIter =
            connectionToTimes.keySet().iterator();
       
        while (connectionIter.hasNext()) {
            HttpConnection conn = connectionIter.next();
            TimeValues times = connectionToTimes.get(conn);
            if(times.timeExpires <= now) {
                if (log.isDebugEnabled()) {
                    log.debug("Closing connection, expired @: "  + times.timeExpires);
                }
                connectionIter.remove();
                try {
                    conn.close();
                } catch (IOException ex) {
                    log.debug("I/O error closing connection", ex);
                }
            }
        }       
View Full Code Here

Examples of org.apache.http.HttpConnection

        if (log.isDebugEnabled()) {
            log.debug("Checking for connections, idle timeout: "  + idleTimeout);
        }

        for (Entry<HttpConnection, TimeValues> entry : connectionToTimes.entrySet()) {
            HttpConnection conn = entry.getKey();
            TimeValues times = entry.getValue();
            long connectionTime = times.timeAdded;
            if (connectionTime <= idleTimeout) {
                if (log.isDebugEnabled()) {
                    log.debug("Closing idle connection, connection time: "  + connectionTime);
                }
                try {
                    conn.close();
                } catch (IOException ex) {
                    log.debug("I/O error closing connection", ex);
                }
            }
        }
View Full Code Here

Examples of org.apache.http.HttpConnection

        if (log.isDebugEnabled()) {
            log.debug("Checking for expired connections, now: "  + now);
        }

        for (Entry<HttpConnection, TimeValues> entry : connectionToTimes.entrySet()) {
            HttpConnection conn = entry.getKey();
            TimeValues times = entry.getValue();
            if(times.timeExpires <= now) {
                if (log.isDebugEnabled()) {
                    log.debug("Closing connection, expired @: "  + times.timeExpires);
                }
                try {
                    conn.close();
                } catch (IOException ex) {
                    log.debug("I/O error closing connection", ex);
                }
            }
        }
View Full Code Here

Examples of org.apache.http.HttpConnection

       
        Iterator<HttpConnection> connectionIter =
            connectionToTimes.keySet().iterator();
       
        while (connectionIter.hasNext()) {
            HttpConnection conn = connectionIter.next();
            TimeValues times = connectionToTimes.get(conn);
            Long connectionTime = times.timeAdded;
            if (connectionTime.longValue() <= idleTimeout) {
                if (log.isDebugEnabled()) {
                    log.debug("Closing connection, connection time: "  + connectionTime);
                }
                connectionIter.remove();
                try {
                    conn.close();
                } catch (IOException ex) {
                    log.debug("I/O error closing connection", ex);
                }
            }
        }
View Full Code Here

Examples of org.apache.http.HttpConnection

       
        Iterator<HttpConnection> connectionIter =
            connectionToTimes.keySet().iterator();
       
        while (connectionIter.hasNext()) {
            HttpConnection conn = connectionIter.next();
            TimeValues times = connectionToTimes.get(conn);
            if(times.timeExpires <= now) {
                if (log.isDebugEnabled()) {
                    log.debug("Closing connection, expired @: "  + times.timeExpires);
                }
                connectionIter.remove();
                try {
                    conn.close();
                } catch (IOException ex) {
                    log.debug("I/O error closing connection", ex);
                }
            }
        }       
View Full Code Here

Examples of org.apache.tez.runtime.library.shuffle.common.HttpConnection

    boolean connectSucceeded = false;
   
    try {
      URL url = ShuffleUtils.constructInputURL(host.getBaseUrl(), srcAttempts,
        httpConnectionParams.getKeepAlive());
      httpConnection = new HttpConnection(url, httpConnectionParams,
        logIdentifier, jobTokenSecret);
      connectSucceeded = httpConnection.connect();
     
      if (stopped) {
        LOG.info("Detected fetcher has been shutdown after connection establishment. Returning");
View Full Code Here

Examples of org.apache.tomcat.lite.http.HttpConnector.HttpConnection

     * @throws IOException
     */
    public void send(HttpChannel httpCh)
            throws IOException {
        String target = httpCh.getTarget();
        HttpConnection con = null;
        // TODO: check ssl on connection - now if a second request
        // is received on a ssl connection - we just send it
        boolean ssl = httpCh.getRequest().isSecure();

        HttpConnectionPool.RemoteServer remoteServer = null;
        synchronized (hosts) {
            remoteServer = hosts.get(target);
            if (remoteServer == null) {
                remoteServer = new HttpConnectionPool.RemoteServer();
                remoteServer.target = target;
                hosts.put(target, remoteServer);
            }
        }

        // TODO: remove old servers and connections

        // Temp magic - until a better negotiation is defined
        boolean forceSpdy = "SPDY/1.0".equals(httpCh.getRequest().getProtocol());
        if (forceSpdy) {
            // switch back the protocol
            httpCh.getRequest().setProtocol("HTTP/1.1");
        }

        activeRequests.incrementAndGet();
        remoteServer.activeRequests.incrementAndGet();

        // if we already have a spdy connection or explicitely
        // requested.
        if (forceSpdy || remoteServer.spdy != null) {
            synchronized (remoteServer) {
                if (remoteServer.spdy == null) {
                    remoteServer.spdy = new SpdyConnection(httpConnector,
                            remoteServer);
                }
                con = remoteServer.spdy;
            }

            // Will be queued - multiple threads may try to send
            // at the same time, and we need to queue anyways.
            con.sendRequest(httpCh);
        } else {
            synchronized (remoteServer) {
                Http11Connection hcon;
                for (int i = 0; i < remoteServer.connections.size(); i++) {
                    hcon = (Http11Connection) remoteServer.connections.get(i);
View Full Code Here

Examples of org.browsermob.proxy.jetty.http.HttpConnection

        throws ServletException,IOException
    {
        HttpServletRequest httpServletRequest=(HttpServletRequest)servletRequest;
        HttpServletResponse httpServletResponse=(HttpServletResponse)servletResponse;

        HttpConnection httpConnection=
            _servletHandler.getHttpContext().getHttpConnection();
        ServletHttpRequest servletHttpRequest=
            (ServletHttpRequest)httpConnection.getRequest().getWrapper();
       
        // wrap the request and response
        DispatcherRequest request = new DispatcherRequest(httpServletRequest,
                                                          servletHttpRequest,
                                                          type);
        DispatcherResponse response = new DispatcherResponse(request,
                                                             httpServletResponse);       
       
        if (type==Dispatcher.__FORWARD)
            servletResponse.resetBuffer();
       
        // Merge parameters
        String query=_query;
        MultiMap parameters=null;
        if (query!=null)
        {
            Map old_params = httpServletRequest.getParameterMap();
           
            // Add the parameters
            parameters=new MultiMap();
            UrlEncoded.decodeTo(query,parameters,request.getCharacterEncoding());
           
            if (old_params!=null && old_params.size()>0)
            {
                // Merge old parameters.
                Iterator iter = old_params.entrySet().iterator();
                while (iter.hasNext())
                {
                    Map.Entry entry = (Map.Entry)iter.next();
                    String name=(String)entry.getKey();
                    String[] values=(String[])entry.getValue();
                    for (int i=0;i<values.length;i++)
                        parameters.add(name, values[i]);
                }
            }

            request.setParameters(parameters);
           
            String old_query=httpServletRequest.getQueryString();
            if (old_query!=null)
                request.setQuery(query+"&"+old_query);
            else
                request.setQuery(query);
        }
       
        Object old_scope = null;
        try
        {
            if (request.crossContext())
            {
                // Setup new _context
                old_scope=
                    _servletHandler.getHttpContext()
                    .enterContextScope(httpConnection.getRequest(),httpConnection.getResponse());
            }
       
            if (isNamed())
            {
                // No further modifications required.
                if (_servletHandler instanceof WebApplicationHandler)
                {
                    JSR154Filter filter = ((WebApplicationHandler)_servletHandler).getJsr154Filter();
                    if (filter!=null && filter.isUnwrappedDispatchSupported())
                    {
                        filter.setDispatch(request, response);
                        _servletHandler.dispatch(null,httpServletRequest,httpServletResponse,_holder, type);
                    }
                    else
                        _servletHandler.dispatch(null,request,response,_holder, type);
                }
                else
                  _servletHandler.dispatch(null,request,response,_holder, type);
            }
            else
            {  
                // Adjust servlet paths
                request.setPaths(_servletHandler.getHttpContext().getContextPath(),
                                 PathMap.pathMatch(_pathSpec,_pathInContext),
                                 PathMap.pathInfo(_pathSpec,_pathInContext));
       

                // are we wrap over or wrap under
                if (_servletHandler instanceof WebApplicationHandler)
                {
                    JSR154Filter filter = ((WebApplicationHandler)_servletHandler).getJsr154Filter();
                    if (filter!=null && filter.isUnwrappedDispatchSupported())
                    {
                        filter.setDispatch(request, response);
                        _servletHandler.dispatch(_pathInContext,httpServletRequest,httpServletResponse,_holder, type);
                    }
                    else
                        _servletHandler.dispatch(_pathInContext,request,response,_holder, type);
                }
                else
                    _servletHandler.dispatch(_pathInContext,request,response,_holder, type);
               
               
                if (type!=Dispatcher.__INCLUDE)
                    response.close();
                else if (response.isFlushNeeded())
                    response.flushBuffer();
            }
        }
        finally
        {
            // restore _context
            if (request.crossContext())
                _servletHandler.getHttpContext()
                    .leaveContextScope(httpConnection.getRequest(),
                                       httpConnection.getResponse(),
                                       old_scope);
        }  
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.