0

Suppose I have a resource that is hosted on a websocket server, and I wish to validate the response status code 101, after the connection is upgraded, how and which libraries to use. Im currently looking at jayway response library, when I connect to a websocket resource, initially it sends a 200 and then upgrades to 101. So code returns 200, I would like to know how this library can be used for websocket validation.
Sample code is :

String response =given().get()("https://www.ws.com:444/examples/websocket/snake.xhtml")
                    .getResponse().asString();

This returns a 200, but does not return the next response. I might sound a little rusty here, would appreciate if you folks have any idea how to extend it to get status 101 or if you have any other suggestions.

Also, this requirement needs to be extended to handle redirection 30x status codes as well, assume a resource is protected behind an access gateway, when a request comes for this protected resource, the gateway forwards it to identity store for verifying the user, at this time a 302 is returned, once verified, request is sent back to access gateway from where user is able to access websocket resource.

Cœur
  • 37,241
  • 25
  • 195
  • 267
MrKickass
  • 93
  • 1
  • 13
  • Your question vaguely sounds like an [XY problem](https://meta.stackexchange.com/a/66378). What are you trying to do? – Malt Apr 10 '17 at 21:30
  • @Malt Il explain it again I need solution to check status of accessing websocket resource through automation scripts Suppose you access a websocket resource on a web server, it initially responds with a 200 before getting upgraded to 101 status, I want to automate this – MrKickass Apr 11 '17 at 06:21
  • I understood the question, I'm just interested in the problem you're trying to solve. If you're trying to see if a websocket endpoint works, why not use a Websocket client to try to connect to the websocket resource? Or are you building a debugging tool for websocket servers? – Malt Apr 11 '17 at 15:32
  • I have tried to understand how a websocket endpoint works by launching the chrome browser network tool, that provides the necessary headers that explains the change in status. I would like to achieve the same through code, i.e., when I access a http/s resource, code should be able to display the response headers containing the status as well – MrKickass Apr 12 '17 at 06:22

0 Answers0