Skip to content

Instantly share code, notes, and snippets.

@brianm
Created July 30, 2009 00:15
Show Gist options
  • Save brianm/158466 to your computer and use it in GitHub Desktop.
Save brianm/158466 to your computer and use it in GitHub Desktop.
HttpExchange exchange = new HttpExchange() {
private volatile int count = 0;
@Override
public InputStream getRequestContentSource() {
return new ByteArrayInputStream(new byte[0]);
}
@Override
public Buffer getRequestContentChunk() throws IOException {
System.out.println("CHUNK");
switch (count++) {
case 0: return new ByteArrayBuffer("hello ".getBytes());
case 1: return new ByteArrayBuffer("world".getBytes());
default: return null;
}
}
};
exchange.setMethod("POST");
exchange.setURL("http://localhost:8000/");
http.send(exchange);
exchange.waitForDone();
brianm@binky:~/src/ning-nfs$ nc -v -l 8000
POST / HTTP/1.1
Host: localhost:8000
Content-Length: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment