Java based HTTP Client which supports Pipelining
Do you know of any free Java library which support the HTTP pipe开发者_JAVA技巧lining option of HTTP/1.1 ( http://en.wikipedia.org/wiki/HTTP_pipelining ) ?
HTTPClient apparently supports pipelining here:
http://www.innovation.ch/java/HTTPClient/
but I haven't tried it personally and can't verify this.
I don't think you will find any common ones supporting pipe-lining. Jetty HttpClient seems to support it from document but I couldn't make it to do it.
Please note that Pipeline is different from keep-alive. Keep-alive just means reuse the connection but it may still send only one request at a time over the connection. With pipe-lining, you can send several requests at the same time over the same connection and wait for their respective responses.
hotpotato will support pipelining really soon. Performance-wise, it's way superior to Apache's HTTP Client, especially in high concurrency environments (multiple threads using the same instance of the client).
I still need to publish the results but on a LAN test, I'm getting ~7000req/s (hotpotato) vs ~100req/s (apache's). Of course, a great deal of the merit must go to Netty, the amazing framework hotpotato is built upon ;)
If you don't need a fancy full-fledged client, take a look here for a simpler version.
I realize my answer is about a year old, but as this is one of the top links for "java http pipelining", I thought it was relevant.
Hotpotato does indeed now support pipelining, and in my limited experience it's been working great so far. Also has a nice API to boot.
http://hotpotato.biasedbit.com/
EDIT: Looks like this project is now unmaintained and the author recommends the Async HTTP client: https://github.com/ning/async-http-client/
Apache HttpComponents Core 5 supports HTTP/1.1 pipelining. The example could be found here.
精彩评论