Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 11 Monaten, 3 Wochen
Letzter Beitrag:
vor 11 Monaten, 2 Wochen
Beteiligte Autoren:
Arie, ccc2, Fabrice Harari, Ccc2

WM21 - download a file slow with httprequest()

Startbeitrag von Arie am 02.06.2017 13:17


I'm using httprequest() against a simple AWP page to download a file. The file is returned using StringDisplay().
I get the file on the tablet and can save it there fSaveBuffer().

So far so good, I;m using this in an update procedure on the tablet to get updates of my app.

I also tested downloading the apk-file directly form the same webserver. Using the tablet browser. I noticed that downloading a file this way about 10 times faster !! Or you say httprequest() is slooow.

I wonder if that is normal. I would say it is all http-traffic isn't it?


Hi Arie,

I haven't tried, so it's just an idea.

Did you try to send the file using FILEdisplay instead of STRINGDisplay...

My reasonning behind this is that in order to send a string, all binary value would probably have to be encapsulated (URLencode or Base64, I would think), while FileDisplay could work in binary mode.

If my supposition is correct, filedisplay should be significantly faster.

Best regards

von Fabrice Harari - am 02.06.2017 18:46
Hi Arie,

Try use other programming languages to build webservice.
So far node.js +Express is the fastest. Even with ssl enable + encryption AES128 + base64 encode , still 10 times faster than using AWP

von Ccc2 - am 03.06.2017 13:41
Enable compression will save 30% of data . by the way compression not support on WM22 android .

read this post for alt solution

von ccc2 - am 03.06.2017 15:28

Filedisplay does not make any difference. I now use this piece of java code , which does do the job fast !

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public static boolean downloadFile(String fileURL, String saveDir) {

boolean response;
response = false;

try {
response = downloadTheFile(fileURL, saveDir);
} catch (IOException ex) {

return response;

public static boolean downloadTheFile(String fileURL, String saveDir) throws IOException {

URL url = new URL(fileURL);
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
int responseCode = httpConn.getResponseCode();
//String response = new StringBuffer();
StringBuilder response = new StringBuilder();
int bytesRead = -1;
byte[] buffer = new byte[4096];
boolean bresult = false;

// always check HTTP response code first
if (responseCode == HttpURLConnection.HTTP_OK) {
String fileName = "";
String disposition = httpConn.getHeaderField("Content-Disposition");
String contentType = httpConn.getContentType();
int contentLength = httpConn.getContentLength();

if (disposition != null) {
// extracts file name from header field
int index = disposition.indexOf("filename=");
if (index > 0) {
fileName = disposition.substring(index + 10,
disposition.length() - 1);
} else {
// extracts file name from URL
fileName = fileURL.substring(fileURL.lastIndexOf("/") + 1,

// System.out.println("Content-Type = " + contentType);
// System.out.println("Content-Disposition = " + disposition);
// System.out.println("Content-Length = " + contentLength);
// System.out.println("fileName = " + fileName);

// opens input stream from the HTTP connection
InputStream inputStream = httpConn.getInputStream();

if(saveDir != ""){
String saveFilePath = saveDir + File.separator + fileName;

// opens an output stream to save into file
FileOutputStream outputStream = new FileOutputStream(saveFilePath);

while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);


} else {
while ((bytesRead = inputStream.read(buffer)) != -1) {
//Log.d("FBOX", "bytesRead=" + bytesRead);
bresult = true;
else {
Log.d("FBOX",fileURL + " file not downloaded. Server replied HTTP code: " + responseCode);

return true;

von Arie - am 09.06.2017 06:33
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.