Class HttpTester

java.lang.Object
org.eclipse.jetty.http.HttpTester

public class HttpTester extends Object

HTTP Testing helper class.

Example usage:


 try (SocketChannel channel = SocketChannel.open(new InetSocketAddress("www.google.com",80)))
 {
     HttpTester.Request request = HttpTester.newRequest();
     request.setMethod("POST");
     request.setURI("/search");
     request.setVersion(HttpVersion.HTTP_1_0);
     request.put(HttpHeader.HOST, "www.google.com");
     request.put("Content-Type", "application/x-www-form-urlencoded");
     request.setContent("q=jetty%20server");

     ByteBuffer output = request.generate();
     channel.write(output);

     HttpTester.Response response = HttpTester.parseResponse(channel);
     System.err.printf("%s %s %s%n", response.getVersion(), response.getStatus(), response.getReason());
     for (HttpField field : response)
     {
         System.err.printf("%s: %s%n", field.getName(), field.getValue());
     }
     System.err.printf("%n%s%n", response.getContent());
 }