title: HttpURLConnection Fixed Length Mode Causes Time Out
body: <p>I'm using an HttpURLConnection to send a POST to a website to log a user in.  My code:</p>
  
  <pre><code>byte[] queryBytes = query.toString().getBytes();
  
  /* Open the connection to the login page */
  URL url = new URL( urlString );
  HttpURLConnection connection = (HttpURLConnection)url.openConnection();
  
  connection.setConnectTimeout( CONNECTION_TIMEOUT );
  connection.setReadTimeout( CONNECTION_TIMEOUT );
  connection.setRequestProperty( "Accept", "text/html, application/octet-stream" );
  connection.setRequestProperty( "Cache-Control", "max-age=0" );
  
  connection.setFixedLengthStreamingMode( queryBytes.length );
  connection.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded" );
  connection.setRequestProperty( "Origin", ORIGIN );
  connection.setRequestProperty( "Referer", REFERER );
  
  /* Add POST data string */
  connection.setDoOutput( true );
  outputStream = connection.getOutputStream();
  outputStream.write( queryBytes );
  outputStream.close();
  
  /* Execute the POST connection */
  int code = connection.getResponseCode();
  </code></pre>
  
  <p>This causes an IOException on the last line with the following logcat:</p>
  
  <pre><code>06-15 12:03:53.285: E/MyApp(1856): Login: IOException: Read timed out
  06-15 12:03:53.285: E/MyApp(1856): java.net.SocketTimeoutException: Read timed out
  06-15 12:03:53.285: E/MyApp(1856):  at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_read(Native Method)
  06-15 12:03:53.285: E/MyApp(1856):  at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:675)
  06-15 12:03:53.285: E/MyApp(1856):  at libcore.io.Streams.readSingleByte(Streams.java:41)
  06-15 12:03:53.285: E/MyApp(1856):  at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:659)
  06-15 12:03:53.285: E/MyApp(1856):  at libcore.io.Streams.readAsciiLine(Streams.java:201)
  06-15 12:03:53.285: E/MyApp(1856):  at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:560)
  06-15 12:03:53.285: E/MyApp(1856):  at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:813)
  06-15 12:03:53.285: E/MyApp(1856):  at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:274)
  06-15 12:03:53.285: E/MyApp(1856):  at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:486)
  06-15 12:03:53.285: E/MyApp(1856):  at libcore.net.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:134)
  06-15 12:03:53.285: E/MyApp(1856):  at com.myapp.interfaces.SkyWestInterface.login(SkyWestInterface.java:606)
  06-15 12:03:53.285: E/MyApp(1856):  at com.myapp.services.MonthUpdateService.processIntent(MonthUpdateService.java:181)
  06-15 12:03:53.285: E/MyApp(1856):  at com.myapp.services.UpdateService.onHandleIntent(UpdateService.java:237)
  06-15 12:03:53.285: E/MyApp(1856):  at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
  06-15 12:03:53.285: E/MyApp(1856):  at android.os.Handler.dispatchMessage(Handler.java:99)
  06-15 12:03:53.285: E/MyApp(1856):  at android.os.Looper.loop(Looper.java:137)
  06-15 12:03:53.285: E/MyApp(1856):  at android.os.HandlerThread.run(HandlerThread.java:60)
  </code></pre>
  
  <p>If I remove the <code>connection.setFixedLengthStreamingMode( queryBytes.length );</code> line, then it works.  Why is this line causing the time out?  Is it due to the SSL?</p>