Package org.eclipse.jetty.http
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
Modifier and TypeClassDescriptionstatic class
static class
static class
static class
-
Method Summary
Modifier and TypeMethodDescriptionstatic HttpTester.Input
from
(InputStream stream) static HttpTester.Input
static HttpTester.Input
from
(ByteBuffer data) static HttpTester.Input
from
(ReadableByteChannel channel) static HttpTester.Request
static HttpTester.Response
parseHeadResponse
(String response) static HttpTester.Response
parseHeadResponse
(ByteBuffer response) static HttpTester.Request
parseRequest
(InputStream stream) static HttpTester.Request
parseRequest
(String request) static HttpTester.Request
parseRequest
(ByteBuffer buffer) static HttpTester.Request
parseRequest
(ReadableByteChannel channel) static HttpTester.Request
parseRequest
(HttpTester.Input input) static HttpTester.Response
parseResponse
(InputStream stream) static HttpTester.Response
parseResponse
(String response) static HttpTester.Response
parseResponse
(ByteBuffer response) static HttpTester.Response
parseResponse
(ReadableByteChannel channel) static HttpTester.Response
parseResponse
(HttpTester.Input input) static HttpTester.Response
parseResponse
(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
-