03-05-2013 09:45 AM
hi i have a problem with bb 9900 device
when i try to connect to webdav servers like mydrive.ch , mydisk.se
and send upload request to the server it throw 'connection close exception' after uploading 2mb
any idea why this happends ?
03-09-2013 07:20 AM
I have done some uploading to servers in the past on BB java (ConnectionClosedException was very common) and the key to this problem was to send your POST request in consistent chunks (so you don't cause problems for bb jvm by writing too much at once or for server by writing inconsistently sized chunks). I used Sockets for this btw.
So first I would create the http headers including Content-Length: and Content-Type: and convert to bytes and then append some more data (whatever your trying to upload) to make the first chunk 4096 and then loop the rest of the file your uploading and write the chunks 4096 at a time.
If you have your headers correct and have worked out your Content length (this is headers bytes size + file to be uploaded bytes size) correctly the server should give you a response even if it's to let you know it's a invalid request.
Hope this helps. (probably best posting in java forums next time).