use of javax.servlet.http.HttpServlet in project jetty.project by eclipse.
the class HttpClientTest method testHEADWithAcceptHeaderAndSendError.
@Test
public void testHEADWithAcceptHeaderAndSendError() throws Exception {
int status = HttpStatus.BAD_REQUEST_400;
start(new HttpServlet() {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.sendError(status);
}
});
ContentResponse response = client.newRequest(newURI()).method(HttpMethod.HEAD).path(servletPath).header(HttpHeader.ACCEPT, "*/*").send();
Assert.assertEquals(status, response.getStatus());
Assert.assertEquals(0, response.getContent().length);
}
use of javax.servlet.http.HttpServlet in project tomcat by apache.
the class TestMimeHeadersIntegration method setupHeadersTest.
private void setupHeadersTest(Tomcat tomcat) {
Context ctx = tomcat.addContext("", getTemporaryDirectory().getAbsolutePath());
Tomcat.addServlet(ctx, "servlet", new HttpServlet() {
private static final long serialVersionUID = 1L;
@Override
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
res.setContentType("text/plain; charset=ISO-8859-1");
res.getWriter().write("OK");
}
});
ctx.addServletMappingDecoded("/", "servlet");
alv = new HeaderCountLogValve();
tomcat.getHost().getPipeline().addValve(alv);
}
use of javax.servlet.http.HttpServlet in project tomcat by apache.
the class TestExpiresFilter method testUseDefaultConfiguration1.
@Test
public void testUseDefaultConfiguration1() throws Exception {
HttpServlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("image/jpeg");
response.getWriter().print("Hello world");
}
};
validate(servlet, Integer.valueOf(1 * 60));
}
use of javax.servlet.http.HttpServlet in project tomcat by apache.
the class TestExpiresFilter method testUseContentTypeWithoutCharsetExpiresConfiguration.
@Test
public void testUseContentTypeWithoutCharsetExpiresConfiguration() throws Exception {
HttpServlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/xml; charset=iso-8859-1");
response.getWriter().print("Hello world");
}
};
validate(servlet, Integer.valueOf(5 * 60));
}
use of javax.servlet.http.HttpServlet in project tomcat by apache.
the class TestExpiresFilter method testUseContentTypeExpiresConfiguration.
@Test
public void testUseContentTypeExpiresConfiguration() throws Exception {
HttpServlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/xml; charset=utf-8");
response.getWriter().print("Hello world");
}
};
validate(servlet, Integer.valueOf(3 * 60));
}
Aggregations