test2304: verify websocket handling when connection is closed

This commit is contained in:
Daniel Stenberg 2022-12-12 16:50:39 +01:00
parent b716511f0f
commit 86b4b66c54
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 200 additions and 2 deletions

View file

@ -241,7 +241,7 @@ test2100 \
\
test2200 test2201 test2202 test2203 test2204 test2205 \
\
test2300 test2301 test2302 test2303 \
test2300 test2301 test2302 test2303 test2304 \
\
test2500 \
\

68
tests/data/test2304 Normal file
View file

@ -0,0 +1,68 @@
<testcase>
<info>
<keywords>
WebSockets
</keywords>
</info>
#
# Sends a PING + a 5 byte hello TEXT
<reply>
<data nocheck="yes" nonewline="yes">
HTTP/1.1 101 Switching to WebSockets swsclose
Server: test-server/fake
Upgrade: websocket
Connection: Upgrade
Something: else
Sec-WebSocket-Accept: HkPsVga7+8LuxM4RGQ5p9tZHeYs=
%hex[%89%00%81%05hello]hex%
</data>
# allow upgrade
<servercmd>
upgrade
</servercmd>
</reply>
#
# Client-side
<client>
# require debug for the forced CURL_ENTROPY
<features>
debug
ws
</features>
<server>
http
</server>
<name>
WebSockets curl_ws_recv() with closed connection
</name>
<tool>
lib%TESTNUMBER
</tool>
<command>
ws://%HOSTIP:%HTTPPORT/%TESTNUMBER
</command>
</client>
#
# PONG with no data and the 32 bit mask
#
<verify>
<protocol nocheck="yes" crlf="yes">
GET /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: websocket/2304
Accept: */*
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: NDMyMTUzMjE2MzIxNzMyMQ==
</protocol>
<stdout mode="text">
Connection closed
</stdout>
</verify>
</testcase>