Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-22606

http put/post By QNAM uploads much slower than ftp By QNAM or raw QTcpSocket.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • Some future release
    • 4.7.4, 4.8.0
    • Network
    • None
    • Server: win2003sp2, iis6, asp.net, ftp, stable 54Mbps wLan, IP 192.168.0.2
      Client: win2003sp2, QT4.7.4/4.8.0RC1, vs2005, stable 54Mbps wLan, IP 192.168.0.3, file.rar(55MB size),curl(a command line http tools), Google Chrome 11

    Description

      In my opinion, the http post/put method implementations in QNAM are immature. Ftp put using QNAM is five times faster than http put in my personal network, so is the raw QTcpSocket. Here are my five tests results.

      Server: win2003sp2, iis6, asp.net, ftp, stable 54Mbps wLan, IP 192.168.0.2
      Client: win2003sp2, QT4.7.4/4.8.0RC1, vs2005, stable 54Mbps wLan, IP 192.168.0.3, file.rar(55MB size),curl(a command line http tools), Google Chrome 11

      Test-Case Upload-Speed Description
      HTTP-PUT-USING-QNAM steady speed at 160KB/S see the source code below
      HTTP-POST-USING-QNAM steady speed at 160KB/S see the source code below
      FTP-PUT-USING-QNAM about 1MB/S see the source code below
      CURL-COMMAND-HTTP-PUT about 1MB/S HTTP PUT Command: curl.exe -T file.rar http://192.168.0.2/testupload/default.aspx
      RAW-QTcpSocket about 1MB/S modifiy the LoopBack Example into client and server side.
      Google-Chrome-POST about 1MB/S Multipart POST

      Sorry for my bad English!

      main.cpp
      int main(int argc, char *argv[])
      {
      	QCoreApplication a(argc, argv);
      // 	=====FTP PUT Using QNAM======
      // 	QUrl url("ftp://192.168.0.2/file.rar");
      // 	url.setUserName("testupload");
      // 	url.setPassword("testupload");
      // 	url.setPort(21);
      
      	QUrl url("htp://192.168.0.2/testupload/default.aspx");
      
      	QFile file("C:\\file.rar");
      	file.open(QFile::ReadOnly);
      
      	QNetworkAccessManager qnam;
      // 	=====HTTP PUT Using QNAM======
      	QNetworkReply* res = qnam.put(QNetworkRequest(url),&file);
      
      // 	=====HTTP POST Using QNAM======
      // 	QNetworkReply* res = qnam.post(QNetworkRequest(url),&file);
      	
      	QEventLoop loop;
      	
      	QObject::connect(res,SIGNAL(finished()),&loop,SLOT(quit()));
      
      	loop.exec();
      
      	return a.exec();
      }
      
      default.aspx.cs
      using System;
      using System.Data;
      using System.Configuration;
      using System.Collections;
      using System.Web;
      using System.Web.Security;
      using System.Web.UI;
      using System.Web.UI.WebControls;
      using System.Web.UI.WebControls.WebParts;
      using System.Web.UI.HtmlControls;
      using System.IO;
      
      public partial class _Default : System.Web.UI.Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
              if(Request.HttpMethod.ToLower()=="put" || Request.HttpMethod.ToLower()=="post")
              {
                  string filePath="D:\\upload\\file.rar";
      			//make sure that Network_Service(or ASP_NET) and IIS_WPG has the permission to this folder.
                   using (FileStream fs = new FileStream(filePath, FileMode.CreateNew))
                  {
                    byte[] bytes = new byte[8192];
      
                    int bytesRead;
                    while ((bytesRead = Request.InputStream.Read(bytes, 0, bytes.Length)) > 0)
                    {
                      fs.Write(bytes, 0, bytesRead);
                    }
                  }
                  Response.Write("HTTP UPLOAD.OK!");
                  Response.End();
              }
             
          }
      }
      
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            lanchy lanchy
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes