Class HttpTester
java.lang.Object
org.eclipse.jetty.http.HttpTester
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());
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic class -
Method Summary
Modifier and TypeMethodDescriptionstatic HttpTester.Inputfrom(InputStream stream) static HttpTester.Inputstatic HttpTester.Inputfrom(ByteBuffer data) static HttpTester.Inputfrom(ReadableByteChannel channel) static HttpTester.Requeststatic HttpTester.ResponseparseHeadResponse(String response) static HttpTester.ResponseparseHeadResponse(ByteBuffer response) static HttpTester.RequestparseRequest(InputStream stream) static HttpTester.RequestparseRequest(String request) static HttpTester.RequestparseRequest(ByteBuffer buffer) static HttpTester.RequestparseRequest(ReadableByteChannel channel) static HttpTester.RequestparseRequest(HttpTester.Input input) static HttpTester.ResponseparseResponse(InputStream stream) static HttpTester.ResponseparseResponse(String response) static HttpTester.ResponseparseResponse(ByteBuffer response) static HttpTester.ResponseparseResponse(ReadableByteChannel channel) static HttpTester.ResponseparseResponse(HttpTester.Input input) static HttpTester.ResponseparseResponse(HttpTester.Input input, boolean head)
-
Method Details
-
from
-
from
-
from
-
from
-
newRequest
-
parseRequest
-
parseRequest
-
parseRequest
- Throws:
IOException
-
parseRequest
- Throws:
IOException
-
parseRequest
- Throws:
IOException
-
parseHeadResponse
-
parseResponse
-
parseHeadResponse
-
parseResponse
-
parseResponse
- Throws:
IOException
-
parseResponse
- Throws:
IOException
-
parseResponse
- Throws:
IOException
-
parseResponse
public static HttpTester.Response parseResponse(HttpTester.Input input, boolean head) throws IOException - Throws:
IOException
-