Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8240666

Websocket client's OpeningHandshake discards the HTTP response body

XMLWordPrintable

    • b22
    • Verified

      ADDITIONAL SYSTEM INFORMATION :
      Tested with 11, but the code is same in 14 too.

      A DESCRIPTION OF THE PROBLEM :
      `jdk.internal.net.http.websocket.OpeningHandshake#send` passes a `BodyHandlers.discarding()` as `BodyHandler` which does make sense for a successful HTTP upgrade. However, when the server rejects the HTTP upgrade (e.g. 401 'Unauthorized'), it may want to share details about the nature of the problem in the response body. I read through RFC of Websocket (https://tools.ietf.org/html/rfc6455) but did not find explicitly that returning a response body from serverside must not be done. I might be missing something, but discarding the response body is an unnecessary limitation.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a Websocket server implementation so that it rejects HTTP upgrade.
      Fill the response body on server side
      Try establishing connection to the server.
      From the caught `CompletionException` extract the response body: `((WebSocketHandshakeException) e.getCause()).getResponse().body()`

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The response body defined on server side
      ACTUAL -
      `null`

      FREQUENCY : always


            ryadav Rahul Yadav
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: