One-shot raw HTTP exchange. Returns response length, 0 on connect failure. */
| 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) { |
| 137 | th_sock_t s = th_connect(port); |
| 138 | if (s == TH_SOCK_BAD) |
| 139 | return 0; |
| 140 | if (th_send_all(s, request, strlen(request)) != 0) { |
| 141 | th_sock_close(s); |
| 142 | return 0; |
| 143 | } |
| 144 | int n = th_recv_until_close(s, resp, respsz); |
| 145 | th_sock_close(s); |
| 146 | return n; |
| 147 | } |
| 148 | |
| 149 | /* Existing route tests focus on endpoint behavior. Add the loopback Host and |
| 150 | * JSON mutation header the browser supplies. Security tests use th_http_raw() |
no test coverage detected