curl/tests/data/test2300
Stefan Eissing 454beb711b
websocket: support CURLOPT_READFUNCTION
Add support for CURLOPT_READFUNCTION with WebSocket urls when
    *not* in connect-only mode, e.g. when using curl_multi_perform.

    Install the callback function and set CURLOPT_UPLOAD. Return
    CURL_READFUNC_PAUSE when having nothing more to send and unpause
    the transfer when more data is ready.

    This will send the read bytes in a WebSocket BINARY frame.

    Add support for this mode in the pytest "ws_data" client and
    have all tests run in 'curl_ws_send/recv' and 'peform' mode
    as well.

    Add `curl_ws_start_frame()`. Document, cover in libcurl-ws.md
    and explain the READFUNCTION mode for websockets.

    Add example `websocket-updown` for this.
2025-07-31 10:51:22 +02:00

65 lines
968 B
Text

<testcase>
<info>
<keywords>
WebSockets
</keywords>
</info>
#
# Server-side
<reply>
<data nocheck="yes">
HTTP/1.1 101 Switching to WebSockets swsclose
Server: test-server/fake
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: HkPsVga7+8LuxM4RGQ5p9tZHeYs=
</data>
# allow upgrade
<servercmd>
upgrade
</servercmd>
</reply>
#
# Client-side
<client>
# require Debug for the forced CURL_ENTROPY
<features>
Debug
ws
</features>
<setenv>
CURL_ENTROPY=12345678
</setenv>
<server>
http
</server>
<name>
WebSockets upgrade only
</name>
<command>
-T . ws://%HOSTIP:%HTTPPORT/%TESTNUMBER
</command>
</client>
#
# Verify data after the test has been "shot"
<verify>
<protocol nocheck="yes">
GET /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: NDMyMTUzMjE2MzIxNzMyMQ==
</protocol>
<errorcode>
52
</errorcode>
</verify>
</testcase>