/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package tests.support; import java.io.IOException; import java.io.InputStream; /* import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.mortbay.jetty.HttpConnection; import org.mortbay.jetty.Request; import org.mortbay.jetty.Server; import org.mortbay.jetty.handler.AbstractHandler; import org.mortbay.jetty.handler.ResourceHandler; import org.mortbay.jetty.servlet.Context; import org.mortbay.jetty.servlet.ServletHolder; */ public class Support_Jetty { /* public static Server DEFAULT_SERVER = null; public static int DEFAULT_PORT = 0; public static Server DEFAULT_SERVLET = null; public static int DEFAULT_SERVLET_PORT = 0; public static Server SERVER = null; public static int PORT = 0; static { Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { stopDefaultServer(); stopServer(); stopDefaultServlet(); } catch (Exception e) { e.printStackTrace(); } } }); } private static class HYDefaultServlet extends HttpServlet { private static final long serialVersionUID = -7650071946216123835L; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { InputStream in = request.getInputStream(); int i; StringBuilder s = new StringBuilder(); while((i = in.read())!=-1){ s.append((char)i); } response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().print(s); } } private static class HYDefaultHandler extends AbstractHandler { public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException { Request base_request = (request instanceof Request) ? (Request)request:HttpConnection.getCurrentConnection().getRequest(); base_request.setHandled(true); response.setContentType("text/html"); response.addDateHeader("Date", System.currentTimeMillis()); response.addDateHeader("Last-Modified", Support_Configuration.URLConnectionLastModified); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().print("