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