Qt World Summit: Register Today!

QHttpMultiPart generates different boundary

  • When I try to upload files by QHttpMultiPart , there appears a problem. I use the CommonsMultipartResolver.isMultipart() to validate the request, and it returns false.

    So I capture frame by Wireshark, and I found an interesting thing: the boundaries in the frame are all different.
    alt text

    Here is my client code

        QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
        QHttpPart zipPart;
        zipPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/zip"));
        zipPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"file\""));
        QFile *file = new QFile(pakPath);
        QNetworkRequest *request = new QNetworkRequest(QUrl(url));
        manager->put(*request, multiPart);

    And the server code

        if( multipartResolver.isMultipart(request) ) {    // here return false

    I have two questions:
    Q1: Is the different boundary make itself be an abnormal in CommonsMultipartResolver?
    Q2: Is Different boundary normal or Qt make mistake?

  • Moderators

    that's correct per definition

    First the boundary is defined: "boundary_.oOo._MjMyNDk=MjMyNDk=MjA1MTM=MTI2Njc="
    Then the (second) boundary denotes the beginning of the multipart data, by prefixing "--".
    The end of the multipart data is then defined by prefixing and suffixing "--".

Log in to reply