I\'m using the Apache HttpClient 4 and it works fine. The only thing that doesn\'t work is custom ports. It seems like the root directory is fetched and the port is ignored.
The problem was that the server does not understand HTTP 1.1 chunked transfers. I cached the data by using a ByteArrayEntity and all was ok.
So custom ports do work with the code mentioned above.