Package org.jboss.com.sun.net.httpserver

Examples of org.jboss.com.sun.net.httpserver.Headers


        int invocation = 1;
        public void handle (HttpExchange t)
            throws IOException
        {
            InputStream is = t.getRequestBody();
            Headers map = t.getRequestHeaders();
            Headers rmap = t.getResponseHeaders();
            while (is.read () != -1) ;
            is.close();
            t.sendResponseHeaders (200, -1);
            t.close();
            requests ++;
View Full Code Here


        volatile int invocation = 0;
        public void handle (HttpExchange t)
            throws IOException
        {
            InputStream is = t.getRequestBody();
            Headers map = t.getRequestHeaders();
            Headers rmap = t.getResponseHeaders();
            int x = invocation ++;
            rmap.set ("XTest", Integer.toString (x));

            switch (x) {
            case 0:
                checkBody (is, body1);
                break;
View Full Code Here

        int invocation = 1;
        public void handle (HttpExchange t)
            throws IOException
        {
            InputStream is = t.getRequestBody();
            Headers map = t.getRequestHeaders();
            Headers rmap = t.getResponseHeaders();
            while (is.read () != -1) ;
            is.close();
            String response = test_input;
            t.sendResponseHeaders (200, response.length());
            OutputStream os = t.getResponseBody();
View Full Code Here

     */
    public void doFilter (HttpExchange t, Filter.Chain chain) throws IOException
    {
        chain.doFilter (t);
        HttpContext context = t.getHttpContext();
        Headers rmap = t.getRequestHeaders();
        String s = df.format (new Date());
        s = s +" " + t.getRequestMethod() + " " + t.getRequestURI() + " ";
        s = s +" " + t.getResponseCode () +" " + t.getRemoteAddress();
        ps.println (s);
    }
View Full Code Here

        volatile int invocation = 0;
        public void handle (HttpExchange t)
            throws IOException
        {
            InputStream is = t.getRequestBody();
            Headers map = t.getRequestHeaders();
            Headers rmap = t.getResponseHeaders();
            int x = invocation ++;
            rmap.set ("XTest", Integer.toString (x));

            switch (x) {
            case 0:
                try {Thread.sleep (2000); } catch (Exception e) {}
                checkBody (is, body1);
View Full Code Here

        public void handle (HttpExchange t)
            throws IOException
        {
            int count = 0;
            InputStream is = t.getRequestBody();
            Headers map = t.getRequestHeaders();
            Headers rmap = t.getResponseHeaders();
            while (is.read () != -1) {
                count ++;
            }
            if (count != 22) {
                System.out.println ("Handler expected 22. got " + count);
View Full Code Here

        int invocation = 1;
        public void handle (HttpExchange t)
            throws IOException
        {
            InputStream is = t.getRequestBody();
            Headers map = t.getRequestHeaders();
            Headers rmap = t.getResponseHeaders();
            int c, count=0;
            while ((c=is.read ()) != -1) {
                if (c != (count % 100)) {
                    error = true;
                    break;
View Full Code Here

        int invocation = 1;
        public void handle (HttpExchange t)
            throws IOException
        {
            InputStream is = t.getRequestBody();
            Headers map = t.getRequestHeaders();
            Headers rmap = t.getResponseHeaders();
            while (is.read () != -1) ;
            is.close();
            t.sendResponseHeaders (200, -1);
            t.close();
        }
View Full Code Here

        int invocation = 1;
        public void handle (HttpExchange t)
            throws IOException
        {
            InputStream is = t.getRequestBody();
            Headers map = t.getRequestHeaders();
            Headers rmap = t.getResponseHeaders();
            URI uri = t.getRequestURI();
            String path = uri.getPath();

            while (is.read () != -1) ;
            is.close();
            File f = new File (docroot, path);
            if (!f.exists()) {
                notfound (t, path);
                return;
            }
            String fixedrequest = map.getFirst ("XFixed");

            String method = t.getRequestMethod();
            if (method.equals ("HEAD")) {
                rmap.set ("Content-Length", Long.toString (f.length()));
                t.sendResponseHeaders (200, -1);
                t.close();
            } else if (!method.equals("GET")) {
                t.sendResponseHeaders (405, -1);
                t.close();
                return;
            }

            if (path.endsWith (".html") || path.endsWith (".htm")) {
                rmap.set ("Content-Type", "text/html");
            } else {
                rmap.set ("Content-Type", "text/plain");
            }
            if (f.isDirectory()) {
                if (!path.endsWith ("/")) {
                    moved (t);
                    return;
                }
                rmap.set ("Content-Type", "text/html");
                t.sendResponseHeaders (200, 0);
                String[] list = f.list();
                OutputStream os = t.getResponseBody();
                PrintStream p = new PrintStream (os);
                p.println ("<h2>Directory listing for: " + path+ "</h2>");
View Full Code Here

                os.close();
            }
        }

        void moved (HttpExchange t) throws IOException {
            Headers req = t.getRequestHeaders();
            Headers map = t.getResponseHeaders();
            URI uri = t.getRequestURI();
            String host = req.getFirst ("Host");
            String location = "http://"+host+uri.getPath() + "/";
            map.set ("Content-Type", "text/html");
            map.set ("Location", location);
            t.sendResponseHeaders (301, -1);
            t.close();
        }
View Full Code Here

TOP

Related Classes of org.jboss.com.sun.net.httpserver.Headers

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.