Read until the server closes the connection (Connection: close model). */
| 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) { |
| 118 | size_t off = 0; |
| 119 | for (;;) { |
| 120 | #ifdef _WIN32 |
| 121 | int n = recv(s, buf + off, (int)(bufsz - 1 - off), 0); |
| 122 | #else |
| 123 | ssize_t n = recv(s, buf + off, bufsz - 1 - off, 0); |
| 124 | #endif |
| 125 | if (n <= 0) |
| 126 | break; |
| 127 | off += (size_t)n; |
| 128 | if (off >= bufsz - 1) |
| 129 | break; |
| 130 | } |
| 131 | buf[off] = '\0'; |
| 132 | return (int)off; |
| 133 | } |
| 134 | |
| 135 | /* One-shot raw HTTP exchange. Returns response length, 0 on connect failure. */ |
| 136 | static int th_http_raw(int port, const char *request, char *resp, size_t respsz) { |
no outgoing calls
no test coverage detected