Search in sources :

Example 1 with SimpleBuffers

use of org.mortbay.io.SimpleBuffers 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();
}
Also used : Buffer(org.mortbay.io.Buffer) ByteArrayBuffer(org.mortbay.io.ByteArrayBuffer) HttpFields(org.mortbay.jetty.HttpFields) ByteArrayEndPoint(org.mortbay.io.ByteArrayEndPoint) HttpParser(org.mortbay.jetty.HttpParser) HttpGenerator(org.mortbay.jetty.HttpGenerator) ByteArrayBuffer(org.mortbay.io.ByteArrayBuffer) SimpleBuffers(org.mortbay.io.SimpleBuffers)

Aggregations

Buffer (org.mortbay.io.Buffer)1 ByteArrayBuffer (org.mortbay.io.ByteArrayBuffer)1 ByteArrayEndPoint (org.mortbay.io.ByteArrayEndPoint)1 SimpleBuffers (org.mortbay.io.SimpleBuffers)1 HttpFields (org.mortbay.jetty.HttpFields)1 HttpGenerator (org.mortbay.jetty.HttpGenerator)1 HttpParser (org.mortbay.jetty.HttpParser)1