Results 1 to 2 of 2

Thread: HTTP Range Option Error 206

  1. #1
    Join Date
    Mar 2010
    Posts
    92
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default HTTP Range Option Error 206

    Hi dear all,

    I'm reading the code of QT attached http sample(examples\network\http).

    In HttpWindow::downloadFile(), I added a key&value pair to the
    QHttpRequestHeader, like this:



    Qt Code:
    1. void HttpWindow::downloadFile()
    2. {
    3. QString qsLink = urlLineEdit->text();
    4. QUrl quUrl(qsLink);
    5. QString qsUrlPath = quUrl.path();
    6. QFileInfo qfiFileInfor(qsUrlPath);
    7. QString qsFileName = qfiFileInfor.fileName();
    8. if (qsFileName.isEmpty())
    9. qsFileName = "index.html";
    10.  
    11. if (QFile::exists(qsFileName)) {
    12. if (QMessageBox::question(this, tr("HTTP"), tr("There already exists a file called %1 in the current directory. Overwrite?").arg(qsFileName), QMessageBox::Yes|QMessageBox::No, QMessageBox::No)== QMessageBox::No){
    13. return;
    14. }
    15. QFile::remove(qsFileName);
    16. }
    17. qfFileOut = new QFile(qsFileName);
    18. if (!qfFileOut->open(QIODevice::WriteOnly)) {
    19. QMessageBox::information(this, tr("HTTP"),tr("Unable to save the file %1: %2.").arg(qsFileName).arg(qfFileOut->errorString()));
    20. delete qfFileOut;
    21. qfFileOut = 0;
    22. return;
    23. }
    24. QString qsHost = quUrl.host();
    25. QHttp::ConnectionMode qhconMode = quUrl.scheme().toLower() == "https" ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp;
    26. qhHttp->setHost(qsHost, qhconMode, quUrl.port() == -1 ? 0 : quUrl.port());
    27. if (!quUrl.userName().isEmpty())
    28. qhHttp->setUser(quUrl.userName(), quUrl.password());
    29. bHttpRequestAborted = false;
    30. QByteArray qbaUrlPath = QUrl::toPercentEncoding(qsUrlPath, "!$&'()*+,;=:@/");
    31. if (qbaUrlPath.isEmpty())
    32. qbaUrlPath = "/";//_________________________________________
    33. QHttpRequestHeader *qhrhHeader = new QHttpRequestHeader("GET", qbaUrlPath);
    34. qhrhHeader->setValue("Connection", "Keep-Alive");
    35. qhrhHeader->setValue("Accept-Ranges", "byte");
    36. /*qhrhHeader->setValue("Content-Length", "1024");
    37. qhrhHeader->setValue("Content-Type", "application/x-rar-compressed");*/
    38. qhrhHeader->setValue("User-Agent", "Mozilla/5.0");
    39. qhrhHeader->setValue("Range", "bytes=0-999");
    40. qhrhHeader->setValue("Host", qsHost);
    41. iHttpGetId = qhHttp->request(*qhrhHeader, 0, qfFileOut);//_________________________________
    42. qpProgressDialog->setWindowTitle(tr("HTTP"));
    43. qpProgressDialog->setLabelText(tr("Downloading %1.").arg(qsFileName));
    44. downloadButton->setEnabled(false);
    45. }
    To copy to clipboard, switch view to plain text mode 


    but when i build it return on funcition is 206





    10.2.7 206 Partial Content

    The server has fulfilled the partial GET request for the resource. The request MUST have included a Range header field (section 14.35) indicating the desired range, and MAY have included an If-Range header field (section 14.27) to make the request conditional.

    The response MUST include the following header fields:

    - Either a Content-Range header field (section 14.16) indicating
    the range included with this response, or a multipart/byteranges
    Content-Type including Content-Range fields for each part. If a
    Content-Length header field is present in the response, its
    value MUST match the actual number of OCTETs transmitted in the
    message-body.

    - Date

    - ETag and/or Content-Location, if the header would have been sent
    in a 200 response to the same request

    - Expires, Cache-Control, and/or Vary, if the field-value might
    differ from that sent in any previous response for the same
    variant

    If the 206 response is the result of an If-Range request that used a strong cache validator (see section 13.3.3), the response SHOULD NOT include other entity-headers. If the response is the result of an If-Range request that used a weak validator, the response MUST NOT include other entity-headers; this prevents inconsistencies between cached entity-bodies and updated headers. Otherwise, the response MUST include all of the entity-headers that would have been returned with a 200 (OK) response to the same request.

    A cache MUST NOT combine a 206 response with other previously cached content if the ETag or Last-Modified headers do not match exactly, see 13.5.4.

    A cache that does not support the Range and Content-Range headers MUST NOT cache 206 (Partial) responses.

    can you help me and edit my source

    http://www.mediafire.com/?dzjaztigrnm

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: HTTP Range Option Error 206

    Will you please stop double posting. Post in one forum ONLY.

    There are replies in your other topic.

Similar Threads

  1. The "Range" option in QHttpRequestHeader
    By nhs_0702 in forum Qt Programming
    Replies: 1
    Last Post: 20th April 2010, 11:54
  2. The "Range" option in QHttpRequestHeader does not work?
    By nhs_0702 in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2010, 09:36
  3. setWritingSystem gives "out of range" error
    By jano_alex_es in forum Newbie
    Replies: 0
    Last Post: 2nd October 2009, 11:33
  4. Out of range detection
    By zgulser in forum Qt Programming
    Replies: 2
    Last Post: 6th February 2009, 09:32
  5. qapplication error when -DQT3_SUPPORT option
    By herachiel in forum Qt Programming
    Replies: 3
    Last Post: 28th June 2006, 14:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.