Commit 5d77784
fix: preserve binary message bodies when serializing to the wire (#126)
SIP message bodies are opaque octets (RFC 3261 §7.4), but messages were
serialized via Display/to_string(), which renders the body with
String::from_utf8_lossy. Any non-UTF-8 body (e.g. an application/ISUP part
or a binary eCall MSD) was corrupted: each invalid byte became U+FFFD,
which changes the payload and breaks Content-Length.
The receive path already preserves binary bodies (the parser slices by
Content-Length), so send and receive were asymmetric.
Add to_bytes() to Request/Response/SipMessage (start line + headers as
ASCII, body appended verbatim) and route the UDP and TCP/TLS transports
through it. From<_> for Vec<u8> now delegates to to_bytes(). Display is
left lossy for human-readable logging. WebSocket is unchanged: SIP-over-WS
(RFC 7118) uses UTF-8 text frames.
Adds regression tests for Request/Response round-trips and the stream codec.
Co-authored-by: Wael Jami <wael.jami@vedecom.fr>1 parent fa70e8f commit 5d77784
3 files changed
Lines changed: 123 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
363 | 386 | | |
364 | 387 | | |
365 | 388 | | |
| |||
406 | 429 | | |
407 | 430 | | |
408 | 431 | | |
409 | | - | |
| 432 | + | |
410 | 433 | | |
411 | 434 | | |
412 | 435 | | |
| |||
507 | 530 | | |
508 | 531 | | |
509 | 532 | | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
510 | 552 | | |
511 | 553 | | |
512 | 554 | | |
| |||
553 | 595 | | |
554 | 596 | | |
555 | 597 | | |
556 | | - | |
| 598 | + | |
557 | 599 | | |
558 | 600 | | |
559 | 601 | | |
| |||
605 | 647 | | |
606 | 648 | | |
607 | 649 | | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
608 | 663 | | |
609 | 664 | | |
610 | 665 | | |
| |||
673 | 728 | | |
674 | 729 | | |
675 | 730 | | |
676 | | - | |
| 731 | + | |
677 | 732 | | |
678 | 733 | | |
679 | 734 | | |
| |||
767 | 822 | | |
768 | 823 | | |
769 | 824 | | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
770 | 858 | | |
771 | 859 | | |
772 | 860 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
140 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| |||
264 | 265 | | |
265 | 266 | | |
266 | 267 | | |
267 | | - | |
| 268 | + | |
268 | 269 | | |
269 | 270 | | |
270 | 271 | | |
| |||
324 | 325 | | |
325 | 326 | | |
326 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
327 | 351 | | |
328 | 352 | | |
329 | 353 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
215 | 217 | | |
216 | | - | |
| 218 | + | |
217 | 219 | | |
218 | 220 | | |
219 | 221 | | |
220 | | - | |
| 222 | + | |
221 | 223 | | |
222 | 224 | | |
223 | 225 | | |
| |||
0 commit comments