use of org.mortbay.jetty.HttpGenerator in project application by collectionspace.
the class UTF8SafeHttpTester method request_binary.
public void request_binary(ServletTester tester, String method, String path, byte[] data, String cookie, String content_type) throws Exception {
Buffer bb = new ByteArrayBuffer(32 * 1024 + (data != null ? data.length : 0));
Buffer sb = new ByteArrayBuffer(4 * 1024);
ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[] {}, 1);
endp.setGrowOutput(true);
HttpGenerator generator = new HttpGenerator(new SimpleBuffers(new Buffer[] { sb, bb }), endp, sb.capacity(), bb.capacity());
generator.setRequest(method, path);
generator.setVersion(HttpVersions.HTTP_1_0_ORDINAL);
HttpFields fields = new HttpFields();
fields.put("Host", "tester");
fields.put(HttpHeaders.CONTENT_TYPE, content_type);
fields.put(HttpHeaders.COOKIE, cookie);
if (data != null)
fields.putLongField(HttpHeaders.CONTENT_LENGTH, data.length);
generator.completeHeader(fields, false);
if (data != null)
generator.addContent(new ByteArrayBuffer(data), false);
generator.complete();
generator.flush();
ByteArrayBuffer res = tester.getResponses(endp.getOut());
HttpParser parser = new HttpParser(res, new PH());
parser.parse();
}
Aggregations