Package org.astrogrid.samp.httpd

Examples of org.astrogrid.samp.httpd.ServerResource


        public HttpServer.Response serveRequest(HttpServer.Request request) {
            String path = request.getUrl();
            if (!path.startsWith(basePath_)) {
                return null;
            }
            final ServerResource resource =
                    resourceMap_.get(path);
            if (resource == EXPIRED) {
                return HttpServer.createErrorResponse(410, "Gone");
            } else if (resource != null) {
                Map<String,String> hdrMap = new HashMap<String,String>();
                hdrMap.put("Content-Type", resource.getContentType());
                long contentLength = resource.getContentLength();
                if (contentLength >= 0) {
                    hdrMap.put("Content-Length",
                            Long.toString(contentLength));
                }
                String method = request.getMethod();
                if (method.equals("HEAD")) {
                    return new HttpServer.Response(200, "OK", hdrMap) {
                        public void writeBody(OutputStream out) {
                        }
                    };
                } else if (method.equals("GET")) {
                    return new HttpServer.Response(200, "OK", hdrMap) {
                        public void writeBody(OutputStream out)
                                throws IOException {
                            resource.writeBody(out);
                        }
                    };
                } else {
                    return HttpServer
                            .createErrorResponse(405, "Unsupported method");
View Full Code Here


         *
         * @param table table
         * @return servable resource
         */
        private ServerResource createResource(final StarTable table) {
            return new ServerResource() {
                public long getContentLength() {
                    return -1L;
                }

                public String getContentType() {
View Full Code Here

TOP

Related Classes of org.astrogrid.samp.httpd.ServerResource

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.