Package org.apache.http

Examples of org.apache.http.HttpInetConnection


        this.requestURLPAth = reqLine.getUri();
        this.requestHTTPMethod = reqLine.getMethod();
        this.requestHTTPProtocol = reqLine.getProtocolVersion().toString();

        if (conn instanceof HttpInetConnection) {
            HttpInetConnection inetConn = (HttpInetConnection) conn;
            InetAddress remoteAddr = inetConn.getRemoteAddress();
            if (remoteAddr != null) {
                this.remoteClientIP = remoteAddr.getHostAddress();
            }
        }
View Full Code Here


        @Override
        public void process(HttpRequest request,
                            HttpContext context)
            throws HttpException, IOException {
           
            HttpInetConnection connection
                = (HttpInetConnection)(context.getAttribute(ExecutionContext.HTTP_CONNECTION));
           
            context.setAttribute(   HOST_ADDRESS,
                                    connection.getRemoteAddress().getHostAddress());
        }
View Full Code Here

            headers.put(headerArr[i].getName(), headerArr[i].getValue());
        }
        msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, headers);
        // find the remote party IP address and set it to the message context
        if (conn instanceof HttpInetConnection) {
            HttpInetConnection inetConn = (HttpInetConnection) conn;
            InetAddress remoteAddr = inetConn.getRemoteAddress();
            if (remoteAddr != null) {
                msgContext.setProperty(MessageContext.REMOTE_ADDR, remoteAddr.getHostAddress());
            }
        }
View Full Code Here

        public void handle(
                final HttpRequest request,
                final HttpResponse response,
                final HttpContext context) throws HttpException, IOException {
            HttpInetConnection conn = (HttpInetConnection) context.getAttribute(
                    ExecutionContext.HTTP_CONNECTION);
            ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
            String uri = request.getRequestLine().getUri();
            if (uri.equals("/oldlocation/")) {
                String redirectUrl = this.schemeName + "://localhost:" + conn.getLocalPort() + "/newlocation/";
                response.setStatusLine(ver, this.statuscode);
                response.addHeader(new BasicHeader("Location", redirectUrl));
                response.addHeader(new BasicHeader("Connection", "close"));
            } else if (uri.equals("/newlocation/")) {
                response.setStatusLine(ver, HttpStatus.SC_OK);
View Full Code Here

        public void handle(
                final HttpRequest request,
                final HttpResponse response,
                final HttpContext context) throws HttpException, IOException {
            HttpInetConnection conn = (HttpInetConnection) context.getAttribute(
                    ExecutionContext.HTTP_CONNECTION);
            String redirectUrl = this.url;
            if (!this.absolute) {
                redirectUrl = this.schemeName + "://localhost:" + conn.getLocalPort() + redirectUrl;
            }

            ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
            String uri = request.getRequestLine().getUri();
            if (uri.equals("/oldlocation/")) {
View Full Code Here

            if (pos != -1) {
                String queryString = uri.substring(pos + 1);
                String requestUri = uri.substring(0, pos);
                String requestUrl = uri;
                if (requestUri.indexOf("://") == -1) {
                    HttpInetConnection inetConn = (HttpInetConnection) conn;

                    String hostName = "localhost";
                    ServerConfiguration serverConfig = ServerConfiguration.getInstance();
                    if (serverConfig.getFirstProperty("HostName") != null) {
                        hostName = serverConfig.getFirstProperty("HostName");
                    }

                    requestUrl = "http://" +
                            hostName + ":" + inetConn.getLocalPort() + requestUri;
                }

                String contextPath = cfgCtx.getServiceContextPath();
                int beginIndex = requestUri.indexOf(contextPath) + contextPath.length() + 1;
                AxisService axisService = null;
View Full Code Here

        public void handle(
                final HttpRequest request,
                final HttpResponse response,
                final HttpContext context) throws HttpException, IOException {
            final HttpInetConnection conn = (HttpInetConnection) context.getAttribute(ExecutionContext.HTTP_CONNECTION);
            final String localhost = conn.getLocalAddress().getHostName();
            final int port = conn.getLocalPort();
            final ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
            final String uri = request.getRequestLine().getUri();
            if (uri.equals("/oldlocation/")) {
                response.setStatusLine(ver, this.statuscode);
                response.addHeader(new BasicHeader("Location",
View Full Code Here

            headers.put(headerArr[i].getName(), headerArr[i].getValue());
        }
        msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, headers);
        // find the remote party IP address and set it to the message context
        if (conn instanceof HttpInetConnection) {
            HttpInetConnection inetConn = (HttpInetConnection) conn;
            InetAddress remoteAddr = inetConn.getRemoteAddress();
            if (remoteAddr != null) {
                msgContext.setProperty(MessageContext.REMOTE_ADDR, remoteAddr.getHostAddress());
            }
        }
View Full Code Here

    private String formatState(final NHttpConnection conn, final HttpExchange httpexchange) {
        StringBuilder buf = new StringBuilder();
        buf.append("[");
        if (conn.isOpen() && (conn instanceof HttpInetConnection)) {
            HttpInetConnection inetconn = (HttpInetConnection) conn;
            buf.append(inetconn.getRemoteAddress());
            buf.append(":");
            buf.append(inetconn.getRemotePort());
        }
        buf.append("(");
        buf.append(conn.isOpen() ? "open" : "closed");
        buf.append("),request=");
        buf.append(httpexchange.getRequestState());
View Full Code Here

    public void testRequestTargetHostFallback() throws Exception {
        HttpContext context = new BasicHttpContext(null);
        BasicHttpRequest request = new BasicHttpRequest("GET", "/");
        InetAddress address = Mockito.mock(InetAddress.class);
        Mockito.when(address.getHostName()).thenReturn("somehost");
        HttpInetConnection conn = Mockito.mock(HttpInetConnection.class);
        Mockito.when(conn.getRemoteAddress()).thenReturn(address);
        Mockito.when(conn.getRemotePort()).thenReturn(1234);
        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, null);
        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
        RequestTargetHost interceptor = new RequestTargetHost();
        interceptor.process(request, context);
        Header header = request.getFirstHeader(HTTP.TARGET_HOST);
View Full Code Here

TOP

Related Classes of org.apache.http.HttpInetConnection

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.