Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. QHttpMultiPart generates different boundary
Qt 6.11 is out! See what's new in the release blog

QHttpMultiPart generates different boundary

Scheduled Pinned Locked Moved QtWebEngine
2 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wzj1695224
    wrote on last edited by
    #1

    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);
        file->open(QIODevice::ReadOnly);
        zipPart.setBodyDevice(file);
    
        multiPart->append(zipPart);
    
        QNetworkRequest *request = new QNetworkRequest(QUrl(url));
    
        manager->put(*request, multiPart);
    

    And the server code

        CommonsMultipartResolver(request.getSession().getServletContext()); 
        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?

    raven-worxR 1 Reply Last reply
    0
    • W wzj1695224

      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);
          file->open(QIODevice::ReadOnly);
          zipPart.setBodyDevice(file);
      
          multiPart->append(zipPart);
      
          QNetworkRequest *request = new QNetworkRequest(QUrl(url));
      
          manager->put(*request, multiPart);
      

      And the server code

          CommonsMultipartResolver(request.getSession().getServletContext()); 
          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?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @wzj1695224
      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 "--".

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved