@@ -6,7 +6,7 @@ use Protocol::WebSocket::Frame;
66
77repeat_each(2 );
88
9- plan tests => repeat_each() * (blocks() * 4 + 14 );
9+ plan tests => repeat_each() * (blocks() * 4 + 13 );
1010
1111my $ pwd = cwd();
1212
@@ -2007,3 +2007,52 @@ GET /c
20072007a-header = a header value
20082008another-header = another header value
20092009yet-another-header = yet another header value
2010+
2011+
2012+
2013+ === TEST 28 : send invalid close status code
2014+ -- - http_config eval: $::HttpConfig
2015+ -- - config
2016+ location = /c {
2017+ content_by_lua_block {
2018+ local client = require " resty.websocket.client"
2019+ local wb, err = client: new()
2020+ local uri = " ws://127.0.0.1:" .. ngx. var. server_port .. " /s"
2021+ local ok , err = wb: connect(uri)
2022+ if not ok then
2023+ ngx. say (" failed to connect: " .. err)
2024+ return
2025+ end
2026+
2027+ local data, typ, err = wb: recv_frame()
2028+ if not data then
2029+ ngx. say (" failed to receive: " , err)
2030+ return
2031+ end
2032+
2033+ ngx. say (" received " , typ, " : " , data, " : " , err)
2034+ }
2035+ }
2036+
2037+ location = /s {
2038+ content_by_lua_block {
2039+ local server = require " resty.websocket.server"
2040+ local wb, err = server: new()
2041+ if not wb then
2042+ ngx. log (ngx. ERR, " failed to new websocket: " , err)
2043+ return ngx. exit(444 )
2044+ end
2045+
2046+ local bytes , err = wb: send_close(0xf000 , " client, let\'s close!" )
2047+ if not bytes then
2048+ ngx. log (ngx. ERR, " failed to send close: " , err)
2049+ return ngx. exit(444 )
2050+ end
2051+ }
2052+ }
2053+ -- - request
2054+ GET / c
2055+ -- - response_body
2056+ failed to receive: failed to receive the first 2 bytes : closed
2057+ -- - error_log
2058+ failed to send close : bad status code
0 commit comments