One-shot raw HTTP exchange. Returns response length, 0 on connect failure. */
| 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) { |
| 151 | th_sock_t s = th_connect(port); |
| 152 | if (s == TH_SOCK_BAD) |
| 153 | return 0; |
| 154 | if (th_send_all(s, request, strlen(request)) != 0) { |
| 155 | th_sock_close(s); |
| 156 | return 0; |
| 157 | } |
| 158 | int n = th_recv_until_close(s, resp, respsz); |
| 159 | th_sock_close(s); |
| 160 | return n; |
| 161 | } |
| 162 | |
| 163 | /* Existing route tests focus on endpoint behavior. Add the loopback Host and |
| 164 | * JSON mutation header the browser supplies. Security tests use th_http_raw() |
no test coverage detected