I useing HttpsURLConnection to do a POST request, sometimes I get the following error back java.io.IOException: unexpected end of stream on com.android.okhttp.Address
but sometimes it works fine, any idea on how to prevent this.
HttpsURLConnection myConnection = (HttpsURLConnection) new URL( tURL ).openConnection();
myConnection.setRequestMethod( "POST" );
myConnection.setRequestProperty("info", "ok");
myConnection.setRequestProperty("type", "car");
myConnection.setRequestProperty("type", tRequestString);
myConnection.setDoOutput(true);
//Adding Post Data
OutputStream outputStream = myConnection.getOutputStream();
outputStream.write(post_data.getBytes());
outputStream.flush();
outputStream.close();
myConnection.setConnectTimeout( 100000 );
myConnection.setReadTimeout( 100000 );
myConnection.connect();
tURL
https://my.url.com/folder/folder2/fileee.cgi