| 99 | } |
| 100 | |
| 101 | static int th_send_all(th_sock_t s, const char *data, size_t len) { |
| 102 | size_t off = 0; |
| 103 | while (off < len) { |
| 104 | #ifdef _WIN32 |
| 105 | int n = send(s, data + off, (int)(len - off), 0); |
| 106 | #else |
| 107 | ssize_t n = send(s, data + off, len - off, 0); |
| 108 | #endif |
| 109 | if (n <= 0) |
| 110 | return -1; |
| 111 | off += (size_t)n; |
| 112 | } |
| 113 | return 0; |
| 114 | } |
| 115 | |
| 116 | /* Read until the server closes the connection (Connection: close model). */ |
| 117 | static int th_recv_until_close(th_sock_t s, char *buf, size_t bufsz) { |
no test coverage detected