Read until the server closes the connection (Connection: close model). */
| 129 | |
| 130 | /* Read until the server closes the connection (Connection: close model). */ |
| 131 | static int th_recv_until_close(th_sock_t s, char *buf, size_t bufsz) { |
| 132 | size_t off = 0; |
| 133 | for (;;) { |
| 134 | #ifdef _WIN32 |
| 135 | int n = recv(s, buf + off, (int)(bufsz - 1 - off), 0); |
| 136 | #else |
| 137 | ssize_t n = recv(s, buf + off, bufsz - 1 - off, 0); |
| 138 | #endif |
| 139 | if (n <= 0) |
| 140 | break; |
| 141 | off += (size_t)n; |
| 142 | if (off >= bufsz - 1) |
| 143 | break; |
| 144 | } |
| 145 | buf[off] = '\0'; |
| 146 | return (int)off; |
| 147 | } |
| 148 | |
| 149 | /* One-shot raw HTTP exchange. Returns response length, 0 on connect failure. */ |
| 150 | static int th_http_raw(int port, const char *request, char *resp, size_t respsz) { |
no outgoing calls
no test coverage detected