perwendel / spark

A simple expressive web framework for java. Spark has a kotlin DSL https://github.com/perwendel/spark-kotlin
Apache License 2.0
9.63k stars 1.56k forks source link

Web socket request gets handled by get route #986

Open RishiRaj22 opened 6 years ago

RishiRaj22 commented 6 years ago

The web socket connection is handled by the get request parameter. Here is my configuration:

webSocket("/test/",Tester.class);
get("/home/",Controller.getHome,templateEngine);
get("/about/",Controller.getAbout,templateEngine);
get("/:param/",Controller.getRoot,templateEngine);

When connecting to the web socket /test, I get the following error: Error during WebSocket handshake: Unexpected response code: 200

Even though the get requests collide, they work together properly, but the same does not happen for websocket connection. Making a websocket connection to /test doesnot work and it instead gets handled by get /:param

Lloyd-Pottiger commented 3 years ago

I would like to work on this issue.

nicetryzz commented 3 years ago

In this issue, method doFilter get the request for target /:param and fill the body, which conflict with web socket request. In order to pass the null value back, I think it need to check if it is the web socket request before doFilter.