×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    18

    HTTP POST request on Nokia N9

    Hello, Forum!

    Here's the situation - I attach some file (JPEG image) to the HTTP POST request so it should be sent to the local server via Wi-Fi and server should return some result (simple text).

    Here's the problem I faced doing this in my Qt-application for Nokia N9 (Meego 1.2 Harmattan).
    After request is sent, proceed by the server and answer is sent back (I can see log on the server) there's a huge delay (about 1 min) before data from server reaches the handset. If answer returns in several parts - the delay is before first part and others are getting very fast (as it should be with the first one too).

    The same code I use in the same app for Symbian^3 (Symbian Anna) on Nokia C6-01 and it works just fine - all the data returns in a couple of seconds (tested in the same network with the same server and request). Also I have several GET requests sending from this app to the same server and all of them works fine too. So it might be the only Meego problem.

    Snippet:
    Code:
    void PostDownloader::sendPostJpgImage(QString url, QImage image) {
            if(mainReply)
            return;
    
        char boundary[] = "AyV04a234DsHeKHcvNds";
    
        image = image.convertToFormat(QImage::Format_RGB888);
    
        QByteArray body;
        QBuffer buffer(&body);
        buffer.open(QIODevice::WriteOnly);
        image.save(&buffer, "JPG");
        buffer.close();
    
        QByteArray b;
        b.append("--").append(boundary).append("\r\n");
        b.append("Content-Disposition: form-data; name=\"jpgfile\"; filename=\"camera\"\r\n");
        b.append("Content-Type: image/jpeg\r\n");
        b.append("\r\n");
        b.append(body);
        b.append("\r\n");
        b.append("--").append(boundary).append("--");
    
        QNetworkRequest req = QNetworkRequest(QUrl(url));
        req.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(QString("multipart/form-data; boundary=")+boundary));
        req.setHeader(QNetworkRequest::ContentLengthHeader, QString::number(b.size()));
        req.setRawHeader("Connection", "Close");
        req.setRawHeader("Cache-Control", "no-cache");
        req.setRawHeader("Keep-Alive", "1");
        mainReply = manager->post(req, b); //POST
    
        connect(mainReply, SIGNAL(readyRead()), this, SLOT(dataReceived()));
        connect(mainReply, SIGNAL(finished()), this, SLOT(finished()));
    }
    So the delay is before calling the dataReceived() slot. How can this can be solved? What can you advice?

    Thanks in advance.

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2009
    Posts
    1,024

    Re: HTTP POST request on Nokia N9

    Weird! My advice? Try to use Wireshark to sniff the network data sent by your application on Symbian and on MeeGo. Then compare the two logs.
    You need more info. Unlikely this is a network problem due to the linux network stack.

Similar Threads

  1. Http Post request response
    By anoopd in forum Symbian Networking & Messaging (Closed)
    Replies: 5
    Last Post: 2010-02-27, 14:12
  2. HTTP Post request structure
    By alav in forum Symbian Networking & Messaging (Closed)
    Replies: 7
    Last Post: 2008-08-12, 10:49
  3. KErrCorrupt in a HTTP Post request
    By deepka in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2008-06-24, 14:06
  4. Error while sending HTTP Post Request
    By bhonsle in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2004-01-11, 16:28

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •