Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] content-type missing in HTTP POST, defaulting to application/octet-stream
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] content-type missing in HTTP POST, defaulting to application/octet-stream

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 24.8k 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.
  • X Offline
    X Offline
    xvision
    wrote on 19 Jun 2012, 17:53 last edited by
    #1

    Just upgraded QT to latest version 4.8.1 libraries on Linux Ubuntu box 10.04 from version 4.7.X.

    With the new version I am receiving an error from our server.
    QT provides the following warning message:
    @content-type missing in HTTP POST, defaulting to application/octet-stream@

    Our server wont accept the posted data. This ran fine with previous release.
    I am aware that the default ContentTypeHeader type needs to be explicitly set under version 4.8.
    However even when adding in the setHeader code shown below, I still receive the same error.

    Any ideas? Do I also need to set the contentHeader length field too or is this handled automatically.

    @ QNetworkRequest request;
    QUrl params;
    params.addQueryItem("version","1.0");
    params.addQueryItem("siteid","12345");
    params.addQueryItem("recordid","12345");

    request.setUrl(serverUrl);
    
    request.setHeader(QNetworkRequest::ContentTypeHeader,QVariant("application/x-www-form-urlencoded"));
    //request.setHeader(QNetworkRequest::ContentLengthHeader,params.encodedQuery().length());
    
    nam->post(QNetworkRequest(serverUrl),params.encodedQuery());
    @
    
    1 Reply Last reply
    0
    • A Offline
      A Offline
      AcerExtensa
      wrote on 20 Jun 2012, 07:08 last edited by
      #2

      contentHeader length is set automatically.

      Sure it wouldn't work. You set headers for request instance but don't use this instance in post request!?

      This:

      @nam->post(QNetworkRequest(serverUrl),params.encodedQuery());@

      should look like this:

      @nam->post(request,params.encodedQuery());@

      God is Real unless explicitly declared as Integer.

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xvision
        wrote on 20 Jun 2012, 07:39 last edited by
        #3

        Thanks AcerExtensa. Need to cut back on the coffee. That worked as expected..

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AcerExtensa
          wrote on 20 Jun 2012, 07:48 last edited by
          #4

          Glad I could help you. Please add "[SOLVED]" to the left of the topic subject.

          God is Real unless explicitly declared as Integer.

          1 Reply Last reply
          0

          3/4

          20 Jun 2012, 07:39

          • Login

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