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());
}
| Modifier and Type | Class and Description |
|---|---|
| public abstract static class | |
| public abstract static class | |
| public static class | |
| public static class |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static HttpTester. | |
| public static HttpTester. | |
| public static HttpTester. | |
| public static HttpTester. | |
| public static HttpTester. | |
| private static void | |
| public static HttpTester. | |
| public static HttpTester. | |
| public static HttpTester. | |
| public static HttpTester. | |
| public static HttpTester. | |
| public static HttpTester. | |
| public static HttpTester. | |
| public static HttpTester. | |
| private static HttpTester. | |
| public static HttpTester. | |
| private static HttpTester. | |
| public static HttpTester. | |
| public static HttpTester. | |
| public static HttpTester. | |
| public static HttpTester. |
| HttpTester | back to summary |
|---|---|
| private HttpTester() | |
| from | back to summary |
|---|---|
| public static HttpTester. | |
| from | back to summary |
|---|---|
| public static HttpTester. | |
| from | back to summary |
|---|---|
| public static HttpTester. | |
| from | back to summary |
|---|---|
| public static HttpTester. | |
| newRequest | back to summary |
|---|---|
| public static HttpTester. | |
| parse | back to summary |
|---|---|
| private static void parse(HttpTester. | |
| parseHeadResponse | back to summary |
|---|---|
| public static HttpTester. | |
| parseHeadResponse | back to summary |
|---|---|
| public static HttpTester. | |
| parseRequest | back to summary |
|---|---|
| public static HttpTester. | |
| parseRequest | back to summary |
|---|---|
| public static HttpTester. | |
| parseRequest | back to summary |
|---|---|
| public static HttpTester. | |
| parseRequest | back to summary |
|---|---|
| public static HttpTester. | |
| parseRequest | back to summary |
|---|---|
| public static HttpTester. | |
| parseResponse | back to summary |
|---|---|
| public static HttpTester. | |
| parseResponse | back to summary |
|---|---|
| private static HttpTester. | |
| parseResponse | back to summary |
|---|---|
| public static HttpTester. | |
| parseResponse | back to summary |
|---|---|
| private static HttpTester. | |
| parseResponse | back to summary |
|---|---|
| public static HttpTester. | |
| parseResponse | back to summary |
|---|---|
| public static HttpTester. | |
| parseResponse | back to summary |
|---|---|
| public static HttpTester. | |
| parseResponse | back to summary |
|---|---|
| public static HttpTester. | |
| Modifier and Type | Field and Description |
|---|---|
| protected final ByteBuffer | |
| protected boolean | |
| protected HttpParser |
| Access | Constructor and Description |
|---|---|
| public | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public abstract int | |
| public ByteBuffer | |
| public boolean | |
| public void | |
| public HttpParser |
| _buffer | back to summary |
|---|---|
| protected final ByteBuffer _buffer | |
| _eof | back to summary |
|---|---|
| protected boolean _eof | |
| _parser | back to summary |
|---|---|
| protected HttpParser _parser | |
| Input | back to summary |
|---|---|
| public Input() | |
| Input | back to summary |
|---|---|
| pack-priv Input(ByteBuffer buffer) | |
| fillBuffer | back to summary |
|---|---|
| public abstract int fillBuffer() throws IOException | |
| getBuffer | back to summary |
|---|---|
| public ByteBuffer getBuffer() | |
| isEOF | back to summary |
|---|---|
| public boolean isEOF() | |
| setHttpParser | back to summary |
|---|---|
| public void setHttpParser(HttpParser parser) | |
| takeHttpParser | back to summary |
|---|---|
| public HttpParser takeHttpParser() | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv boolean | |
| pack-priv ByteArrayOutputStream | |
| pack-priv boolean | |
| pack-priv HttpVersion |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | badMessage(HttpException
the failure with the bad message information failure)Overrides default org. |
| public boolean | |
| public boolean | |
| public void | earlyEOF()
Implements org. |
| public ByteBuffer | |
| public String | |
| public ByteBuffer | |
| public byte[] | |
| public abstract MetaData | |
| public HttpVersion | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| public void | parsedHeader(HttpField
The field parsed field)Implements org. |
| public void | |
| public void | |
| public void | |
| public void | |
| public void |
| _complete | back to summary |
|---|---|
| pack-priv boolean _complete | |
| _content | back to summary |
|---|---|
| pack-priv ByteArrayOutputStream _content | |
| _earlyEOF | back to summary |
|---|---|
| pack-priv boolean _earlyEOF | |
| _version | back to summary |
|---|---|
| pack-priv HttpVersion _version | |
| Message | back to summary |
|---|---|
| public Message() | |
| badMessage | back to summary |
|---|---|
| public void badMessage(HttpException failure) Overrides default org. Doc from org. Called to signal that a bad HTTP message has been received.
| |
| content | back to summary |
|---|---|
| public boolean content(ByteBuffer ref) Implements org.
| |
| contentComplete | back to summary |
|---|---|
| public boolean contentComplete() Implements org.
| |
| earlyEOF | back to summary |
|---|---|
| public void earlyEOF() Implements org. Doc from org. Called to signal that an EOF was received unexpectedly during the parsing of an HTTP message
| |
| generate | back to summary |
|---|---|
| public ByteBuffer generate() | |
| getContent | back to summary |
|---|---|
| public String getContent() | |
| getContentByteBuffer | back to summary |
|---|---|
| public ByteBuffer getContentByteBuffer() | |
| getContentBytes | back to summary |
|---|---|
| public byte[] getContentBytes() | |
| getMetaData | back to summary |
|---|---|
| public abstract MetaData getMetaData() | |
| getVersion | back to summary |
|---|---|
| public HttpVersion getVersion() | |
| headerComplete | back to summary |
|---|---|
| public boolean headerComplete() Implements org.
| |
| isComplete | back to summary |
|---|---|
| public boolean isComplete() | |
| isEarlyEOF | back to summary |
|---|---|
| public boolean isEarlyEOF() | |
| messageComplete | back to summary |
|---|---|
| public boolean messageComplete() Implements org.
| |
| parsedHeader | back to summary |
|---|---|
| public void parsedHeader(HttpField field) Implements org. Doc from org. This is the method called by parser when an HTTP Header name and value is found | |
| setContent | back to summary |
|---|---|
| public void setContent(byte[] bytes) | |
| setContent | back to summary |
|---|---|
| public void setContent(String content) | |
| setContent | back to summary |
|---|---|
| public void setContent(ByteBuffer content) | |
| setVersion | back to summary |
|---|---|
| public void setVersion(String version) | |
| setVersion | back to summary |
|---|---|
| public void setVersion(HttpVersion version) | |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public MetaData. | |
| public String | |
| public String | |
| public void | |
| public void | |
| public void | |
| public void | startRequest(String
The method method, String The raw bytes of the URI. These are copied into a ByteBuffer that will not be changed until this parser is reset and reused. uri, HttpVersion the http version in use version)Implements org. |
| public String | toString()
Overrides org. |
| Request | back to summary |
|---|---|
| public Request() | |
| getMetaData | back to summary |
|---|---|
| public MetaData. Implements abstract org.
| |
| getMethod | back to summary |
|---|---|
| public String getMethod() | |
| getURI | back to summary |
|---|---|
| public String getURI() | |
| setHeader | back to summary |
|---|---|
| public void setHeader(String name, String value) | |
| setMethod | back to summary |
|---|---|
| public void setMethod(String method) | |
| setURI | back to summary |
|---|---|
| public void setURI(String uri) | |
| startRequest | back to summary |
|---|---|
| public void startRequest(String method, String uri, HttpVersion version) Implements org. Doc from org. This is the method called by parser when the HTTP request line is parsed
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Doc from java. Returns a string representation of the object. | |
| Modifier and Type | Field and Description |
|---|---|
| private String | |
| private int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public MetaData. | |
| public String | |
| public int | |
| public void | startResponse(HttpVersion
the http version in use version, int the response status status, String the response reason phrase reason)Implements org. |
| public String | toString()
Overrides org. |
| _reason | back to summary |
|---|---|
| private String _reason | |
| _status | back to summary |
|---|---|
| private int _status | |
| Response | back to summary |
|---|---|
| public Response() | |
| getMetaData | back to summary |
|---|---|
| public MetaData. Implements abstract org.
| |
| getReason | back to summary |
|---|---|
| public String getReason() | |
| getStatus | back to summary |
|---|---|
| public int getStatus() | |
| startResponse | back to summary |
|---|---|
| public void startResponse(HttpVersion version, int status, String reason) Implements org. Doc from org. This is the method called by parser when the HTTP request line is parsed
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Doc from java. Returns a string representation of the object. | |