Package org.apache.commons.httpclient.server

Examples of org.apache.commons.httpclient.server.RequestLine


            this.url = redirectUrl;
        }

        public boolean process(final SimpleRequest request, final SimpleResponse response)
            throws IOException {
            RequestLine reqline = request.getRequestLine();
            HttpVersion ver = reqline.getHttpVersion();
            if (reqline.getUri().equals("/oldlocation/")) {
                response.setStatusLine(ver, HttpStatus.SC_MOVED_TEMPORARILY);
                response.addHeader(new Header("Location", url));
            } else if (reqline.getUri().equals("/relativelocation/")) {
                response.setStatusLine(ver, HttpStatus.SC_OK);
                response.setBodyString("Successful redirect");
            } else {
                response.setStatusLine(ver, HttpStatus.SC_NOT_FOUND);
            }
View Full Code Here


            this(host, port, -1);
        }

        public boolean process(final SimpleRequest request, final SimpleResponse response)
            throws IOException {
            RequestLine reqline = request.getRequestLine();
            HttpVersion ver = reqline.getHttpVersion();
            if (reqline.getUri().equals("/oldlocation/")) {
                response.setStatusLine(ver, this.statuscode);
                response.addHeader(new Header("Location",
                        "http://" + this.host + ":" + this.port + "/newlocation/"));
                response.addHeader(new Header("Connection", "close"));
            } else if (reqline.getUri().equals("/newlocation/")) {
                response.setStatusLine(ver, HttpStatus.SC_OK);
                response.setBodyString("Successful redirect");
            } else {
                response.setStatusLine(ver, HttpStatus.SC_NOT_FOUND);
            }
View Full Code Here

        }
       
        public boolean process(final SimpleRequest request, final SimpleResponse response)
            throws IOException
        {
            RequestLine reqline = request.getRequestLine();
            HttpVersion ver = reqline.getHttpVersion();
            if (reqline.getUri().startsWith("/circular-oldlocation")) {
                response.setStatusLine(ver, HttpStatus.SC_MOVED_TEMPORARILY);
                response.addHeader(new Header("Location", "/circular-location2?invk=" + (++this.invocations)));
            } else if (reqline.getUri().startsWith("/circular-location2")) {
                response.setStatusLine(ver, HttpStatus.SC_MOVED_TEMPORARILY);
                response.addHeader(new Header("Location", "/circular-oldlocation?invk=" + (++this.invocations)));
            } else {
                response.setStatusLine(ver, HttpStatus.SC_NOT_FOUND);
            }
View Full Code Here

    }

    public boolean process(final SimpleRequest request, final SimpleResponse response)
        throws IOException
    {
        RequestLine requestline = request.getRequestLine();
        HttpVersion httpversion = requestline.getHttpVersion();

        StringWriter buffer = new StringWriter(100);
        buffer.write("Method type: ");
        buffer.write(requestline.getMethod());
        buffer.write("\r\n");
        buffer.write("Requested resource: ");
        buffer.write(requestline.getUri());
        buffer.write("\r\n");
        buffer.write("Protocol version: ");
        buffer.write(httpversion.toString());
        buffer.write("\r\n");
       
View Full Code Here

        }

        public boolean process(final SimpleRequest request, final SimpleResponse response)
            throws IOException
        {
            RequestLine reqline = request.getRequestLine();
            HttpVersion ver = reqline.getHttpVersion();
            if (reqline.getUri().equals("/redirect/")) {
                response.setStatusLine(ver, HttpStatus.SC_MOVED_TEMPORARILY);
                response.addHeader(new Header("Location", this.location));
                response.addHeader(new Header("Connection", "Close"));
                return true;
            } else {
View Full Code Here

            super();
        }

        public boolean process(final SimpleRequest request, final SimpleResponse response)
            throws IOException {
            RequestLine reqline = request.getRequestLine();
            HttpVersion ver = reqline.getHttpVersion();
            Header header =  request.getFirstHeader("Host");
            if (header == null) {
                response.setStatusLine(ver, HttpStatus.SC_BAD_REQUEST);
                return true;
            }
View Full Code Here

        public boolean processRequest(
            final SimpleHttpServerConnection conn,
            final SimpleRequest request) throws IOException
        {
            RequestLine requestLine = request.getRequestLine();
            ResponseWriter out = conn.getWriter();
            if ("GET".equals(requestLine.getMethod())
                && "/".equals(requestLine.getUri())) {

                requestNo++;

                out.println("HTTP/1.1 200 OK");
                out.println("Content-Type: text/html");
View Full Code Here

        }

        public boolean process(final SimpleRequest request, final SimpleResponse response)
            throws IOException
        {
            RequestLine requestLine = request.getRequestLine();
            HttpVersion ver = requestLine.getHttpVersion();
            Header auth = request.getFirstHeader("Authorization");
            if (auth == null) {
                response.setStatusLine(ver, HttpStatus.SC_UNAUTHORIZED);
                response.addHeader(new Header("WWW-Authenticate",
                        "Digest realm=\"realm1\", nonce=\"ABC123\""));
View Full Code Here

    }

    public boolean process(final SimpleRequest request, final SimpleResponse response)
        throws IOException
    {
        RequestLine requestline = request.getRequestLine();
        HttpVersion httpversion = requestline.getHttpVersion();

        StringWriter buffer = new StringWriter(100);
        buffer.write("Method type: ");
        buffer.write(requestline.getMethod());
        buffer.write("\r\n");
        buffer.write("Requested resource: ");
        buffer.write(requestline.getUri());
        buffer.write("\r\n");
        buffer.write("Protocol version: ");
        buffer.write(httpversion.toString());
        buffer.write("\r\n");
       
View Full Code Here

        public boolean processRequest(
            final SimpleHttpServerConnection conn,
            final SimpleRequest request) throws IOException
        {
            RequestLine requestLine = request.getRequestLine();
            ResponseWriter out = conn.getWriter();
            if ("GET".equals(requestLine.getMethod())
                && "/".equals(requestLine.getUri())) {

                requestNo++;

                out.println("HTTP/1.1 200 OK");
                out.println("Content-Type: text/html");
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.server.RequestLine

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.