When opening a URLConnection I use the following code in order to get the content length, however it returns -1.
URL url = new URL(sUrl[0]);
URLConnection connection = url.openConnection();
connection.connect();
int fileLength = connection.getContentLength();
I presumed then that the server was not setting a content-length header (and a dig in the connection object confirms the value is -1), and so set one myself using the following in PHP:
header('Content-Length: '.strlen($output));
When I print out the value of strlen($output)
I get the correct value, but this header does not seem to make it to Java.
Any suggestions or further code required? Thanks