curl/tests/http/clients
Stefan Eissing 02edae54e8 websocket: fix message send corruption
- Fix a bug in EAGAIN handling when sending frames that led to a
  corrupted last byte of the frame sent.

- Restore sanity to curl_ws_send() behaviour:

  - Partial writes are reported as OK with the actual number of
    payload bytes sent.

  - CURLE_AGAIN is only returned when none of the payload bytes
    (or for 0-length frames, not all of the frame header bytes)
    could be sent.

  - curl_ws_send() now behaves like a common send() call.

- Change 'ws-data' test client to allow concurrent send/recv
  operations and vary frame sizes and repeat count.

- Add DEBUG env var CURL_WS_CHUNK_EAGAIN to simulate blocking
  after a chunk of an encoded websocket frame has been sent.

- Add tests.


Prior to this change data corruption may occur when sending websocket
messages due to two bugs:

1) 3e64569a (precedes 8.10.0) caused a data corruption bug in the last
   byte of frame of large messages.

2) curl_ws_send had non-traditional send behavior and could return
   CURLE_AGAIN with bytes sent and expect the caller to adjust buffer
   and buflen in a subsequent call. That behavior was not documented.


Reported-by: na-trium-144@users.noreply.github.com

Fixes https://github.com/curl/curl/issues/15865
Fixes https://github.com/curl/curl/issues/15865#issuecomment-2569870144
Closes https://github.com/curl/curl/pull/15901
2025-01-16 16:19:07 -05:00
..
.gitignore request: correctly reset the eos_sent flag 2024-09-13 13:28:10 +02:00
CMakeLists.txt msvc: tidy up _CRT_*_NO_DEPRECATE definitions 2025-01-12 00:34:21 +01:00
h2-pausing.c tests: fix callback signatures to please UndefinedBehaviorSanitizer 2024-10-15 14:33:47 +02:00
h2-serverpush.c lib/src: white space edits to comply better with code style 2024-09-19 14:59:12 +02:00
h2-upgrade-extreme.c build: make CURL_FORMAT_CURL_OFF_T[U] work with mingw-w64 <=7.0.0 2024-08-22 10:45:04 +02:00
hx-download.c conncache: count shutdowns against host and max limits 2025-01-06 23:10:23 +01:00
hx-upload.c TLS: TLSv1.3 earlydata support for curl 2024-10-11 12:28:22 +02:00
Makefile.am build: tidy up deprecation suppression, enable warnings for clang 2024-09-21 00:59:52 +02:00
Makefile.inc request: correctly reset the eos_sent flag 2024-09-13 13:28:10 +02:00
tls-session-reuse.c build: make CURL_FORMAT_CURL_OFF_T[U] work with mingw-w64 <=7.0.0 2024-08-22 10:45:04 +02:00
upload-pausing.c tests: fix callback signatures to please UndefinedBehaviorSanitizer 2024-10-15 14:33:47 +02:00
ws-data.c websocket: fix message send corruption 2025-01-16 16:19:07 -05:00
ws-pingpong.c tests/http/clients: use proper sleep() call on NonStop 2024-12-12 14:30:28 +01:00