Hi,
I want to send a multipart/form-data
request with streaming enabled, the multipart/form-data
request contains some text parts and several binary parts, the binary parts should be streaming to server, in order to streaming the binary to server, I send the binary part one by one and insert some idle time between 2 parts, I have gotten the idle time for streaming. I am new to this http client, I read some tutorial and found that FeedableBodyGenerator may help me, but I don't know where to insert the idle time when sending request, I guess it may insert the idle time in the method onContentAdded of the Listener as follows:
UnboundedQueueFeedableBodyGenerator generator=new UnboundedQueueFeedableBodyGenerator();
generator.setListener(new FeedListener() {
@Override
public void onContentAdded() { // sleep some time here between 2 parts
if(isBinaryPart){
Thread.sleep(idleTime);
}
}
});
AsyncHttpClient client=Dsl.asyncHttpClient();
BoundRequestBuilder builder=client.preparePost("http://127.0.0.1");
builder.setBody(generator);
client.executeRequest(builder.build());
I don't know if the above code works, if it not correct, could you give me some hints on how to implment streaming with this library?
Thanks.