This is definitely NOT normal. How often does a download in your browser fail?? Once a year?
How often does a Java download fail? Every other day? I think this is the root cause of all JavaWebStart problems. I'm starting to get more and more convinced that URLConnection is bugged. I should dive into the code some day.
Some time ago, I had this applet that loaded a bunch of thumbnails from a server. It was quite normal that a few wouldn't get loaded.
So... on to the problem:
HTTP isn't that hard. Just do your own HTTP handling. Add support for "Transfer-Encoding: chunked" and you instantly support 99.99% of all webservers. Cache nothing. Worked for me. The guarantee that all bugs are in *your* code is worth gold.
Absolutly right URLConnection is Buuugged and.... act differently on different JVM ... borring....
Unfortunatly it have a usefull feature that cannot be made using a TCP socket, it is allowed to read browser configuration and especially proxy setting including login, password and IP.
You can go througt HTTP proxy with TCP socket by using
Proxy-Authorization header but you will have to ask the user to enter it login/password and the proxy IP, but finally that may not be a big issue.
if you dont want to implement chunked exchange (or other complexe/heavy HTTP 1.1) features you can make your request with HTTP/1.0 rather than HTTP/1.1
but... another but.... there are several possible issue when implementing HTTP protocole partially, you should especially take care of the following :
Request headers for HTTP 1.1 :Host (requiered for 1.1 request)
Response code for both 1.0 / 1.1:407 : proxy authentication requiered
307/301 : moved => you must do another call to the returned URI/location
I have to deal with Applet/Server communication at work, I choose to make my own HTTP implementation using Socket as mentioned by Riven (the main first reason was a bugged keep-alive implementation on URLConnection), but my Class will keep a fall back to URLConnection and switch to it in case of something go wrong with the direct TCP Socket connection.
finnaly I would recommend the following : connect using your home made HTTP connector and if it fail retry with URLConnection