<commit_before>package unfiltered.netty.websockets

import unfiltered.response.ResponseString
import unfiltered.request.{ Path => UFPath }
import unfiltered.netty

/** tests for an unfiltered web sockets
 *  passing msgs along to a plan that
 *  can handle them
 */
object PassingSpec extends unfiltered.spec.netty.Served {

  def setup =
    _.handler(planify {
      case UFPath("/a") => ResponseString("http response a")
    })
    .handler(netty.websockets.Planify({
      case UFPath("/b") => {
        case Open(s) => s.send("socket opened b")
        case Message(s, Text(msg)) => s.send(msg)
      }
      case UFPath("/c") => Pass
    }).onPass(_.fireChannelRead(_)))
    .handler(netty.cycle.Planify {
      case UFPath("/b") => ResponseString("http response b")
      case UFPath("/c") => ResponseString("http response c")
    })

  "A websocket server" should {
    "not block standard http requests" in {
      http(host / "b" as_str) must_==("http response b")
      http(host / "a" as_str) must_==("http response a")
      http(host / "c" as_str) must_==("http response c")
    }
  }
}<commit_msg>code style<commit_after>package unfiltered.netty.websockets

import unfiltered.response.ResponseString
import unfiltered.request.{ Path => UFPath }
import unfiltered.netty

/** tests for an unfiltered web sockets
 *  passing msgs along to a plan that
 *  can handle them
 */
object PassingSpec extends unfiltered.spec.netty.Served {

  def setup =
    _.handler(planify {
      case UFPath("/a") => ResponseString("http response a")
    })
    .handler(netty.websockets.Planify({
      case UFPath("/b") => {
        case Open(s) => s.send("socket opened b")
        case Message(s, Text(msg)) => s.send(msg)
      }
      case UFPath("/c") => Pass
    })
    .onPass(_.fireChannelRead(_)))
    .handler(netty.cycle.Planify {
      case UFPath("/b") => ResponseString("http response b")
      case UFPath("/c") => ResponseString("http response c")
    })

  "A websocket server" should {
    "not block standard http requests" in {
      http(host / "b" as_str) must_==("http response b")
      http(host / "a" as_str) must_==("http response a")
      http(host / "c" as_str) must_==("http response c")
    }
  }
}
{'fraction_non_alphanumeric': 0.14645103324348607, 'fraction_numerical': 0.0, 'mean_word_length': 3.086238532110092, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6192982', 'n_tokens_mistral': 735, 'n_tokens_neox': 713, 'n_words': 187}