Browse Source

Android: fix web input stream reporting always total length of -1.

tags/2021-05-28
Lukasz Kozakiewicz 8 years ago
parent
commit
c8c692e2b7
2 changed files with 15 additions and 3 deletions
  1. +12
    -3
      modules/juce_core/native/java/JuceAppActivity.java
  2. +3
    -0
      modules/juce_core/network/juce_URL.cpp

+ 12
- 3
modules/juce_core/native/java/JuceAppActivity.java View File

@@ -910,6 +910,7 @@ public class JuceAppActivity extends Activity
timeOutMs = timeOutMsToUse;
statusCode = statusCodeToUse;
responseHeaders = responseHeadersToUse;
totalLength = -1;
numRedirectsToFollow = numRedirectsToFollowToUse;
httpRequestCmd = httpRequestCmdToUse;
@@ -1122,9 +1123,16 @@ public class JuceAppActivity extends Activity
{}
for (java.util.Map.Entry<String, java.util.List<String>> entry : connection.getHeaderFields().entrySet())
{
if (entry.getKey() != null && entry.getValue() != null)
responseHeaders.append (entry.getKey() + ": "
+ android.text.TextUtils.join (",", entry.getValue()) + "\n");
{
responseHeaders.append(entry.getKey() + ": "
+ android.text.TextUtils.join(",", entry.getValue()) + "\n");
if (entry.getKey().compareTo ("Content-Length") == 0)
totalLength = Integer.decode (entry.getValue().get (0));
}
}
return true;
}
@@ -1227,7 +1235,7 @@ public class JuceAppActivity extends Activity
}
public final long getPosition() { return position; }
public final long getTotalLength() { return -1; }
public final long getTotalLength() { return totalLength; }
public final boolean isExhausted() { return false; }
public final boolean setPosition (long newPos) { return false; }
@@ -1239,6 +1247,7 @@ public class JuceAppActivity extends Activity
private HttpURLConnection connection;
private int[] statusCode;
private StringBuffer responseHeaders;
private int totalLength;
private int numRedirectsToFollow;
private InputStream inputStream;
private long position;


+ 3
- 0
modules/juce_core/network/juce_URL.cpp View File

@@ -73,6 +73,9 @@ struct FallbackDownloadTask : public URL::DownloadTask,
}
downloaded += actual;
if (downloaded == contentLength)
break;
}
fileStream->flush();


Loading…
Cancel
Save