Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. HttpsStatusCodeAttribute not working properly.
QtWS25 Last Chance

HttpsStatusCodeAttribute not working properly.

Scheduled Pinned Locked Moved Solved Qt for WebAssembly
4 Posts 2 Posters 318 Views
  • 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.
  • L Offline
    L Offline
    leonidh
    wrote on 27 Jan 2025, 01:31 last edited by
    #1

    Hello,

    I am looking for some help getting the HTTP status codes from messages I receive from my HTTP server.

    auto status = rep->attribute(QNetworkRequest::HttpStatusCodeAttribute);
    

    By using the line above, I am properly receiving replies such as 200 or 204 from the HTTP server when it is compiled as a desktop application. However, when I run it under WebAssembly, the status is always 0 (independent of the actual reply).

    According to the description for HttpStatusCodeAttribute (QNetworkRequest class): "If the connection was not HTTP-based, this attribute will not be present". It looks to me that under WebAssembly this is not treated as an HTTP response.

    I can see proper communication in WireShark, but the result of status variable is incorrect.

    Any recommendations?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leonidh
      wrote on 1 Feb 2025, 13:18 last edited by leonidh 2 Jan 2025, 13:22
      #4

      After some investigation, I don't believe the issue is related to the attribute method. The entire received reply is empty. There are no headers or body received by the application. The Wireshark capture shows that the entire message is properly sent out by my HTTP server and received by the browser, however, the application does not receive it.

      I checked if any error was reported by the reply and received an error QNetworkReply::ProtocolFailure (399). I believe the browser strips that information and does not propagate it further to the application. I tested this in Firefox and Chrome with the same results.

      As I mentioned in my original post, the communication works perfectly when compiled as a desktop application. The issue was only observed when compiled by WebAssembly.

      I will close this post and reopen a new one with a new question.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lorn.potter
        wrote on 28 Jan 2025, 22:27 last edited by
        #2

        Perhaps report a bug? https://bugreports.qt.io

        Freelance Software Engineer, Platform Maintainer QtWebAssembly, Maintainer QtSensors
        Author, Hands-On Mobile and Embedded Development with Qt 5 http://bit.ly/HandsOnMobileEmbedded

        L 1 Reply Last reply 29 Jan 2025, 13:51
        0
        • L lorn.potter
          28 Jan 2025, 22:27

          Perhaps report a bug? https://bugreports.qt.io

          L Offline
          L Offline
          leonidh
          wrote on 29 Jan 2025, 13:51 last edited by
          #3

          @lorn-potter Thank you. I was hoping that I was doing something wrong.
          Do you have any recommendations to get the HTTP response status codes any other way?

          1 Reply Last reply
          0
          • L Offline
            L Offline
            leonidh
            wrote on 1 Feb 2025, 13:18 last edited by leonidh 2 Jan 2025, 13:22
            #4

            After some investigation, I don't believe the issue is related to the attribute method. The entire received reply is empty. There are no headers or body received by the application. The Wireshark capture shows that the entire message is properly sent out by my HTTP server and received by the browser, however, the application does not receive it.

            I checked if any error was reported by the reply and received an error QNetworkReply::ProtocolFailure (399). I believe the browser strips that information and does not propagate it further to the application. I tested this in Firefox and Chrome with the same results.

            As I mentioned in my original post, the communication works perfectly when compiled as a desktop application. The issue was only observed when compiled by WebAssembly.

            I will close this post and reopen a new one with a new question.

            1 Reply Last reply
            0
            • L leonidh has marked this topic as solved on 1 Feb 2025, 13:22

            2/4

            28 Jan 2025, 22:27

            • Login

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