| 188 | } |
| 189 | |
| 190 | static void http_upgrade(int fd) |
| 191 | { |
| 192 | u8 buf[65536]; |
| 193 | size_t len = 0; |
| 194 | |
| 195 | alarm(60); |
| 196 | while (!http_headers_complete(buf, len)) { |
| 197 | int r; |
| 198 | r = read(STDIN_FILENO, buf + len, sizeof(buf) - len); |
| 199 | if (r <= 0) |
| 200 | bad_http(STDIN_FILENO, "No header end after %zu bytes", |
| 201 | len); |
| 202 | len += r; |
| 203 | } |
| 204 | http_respond(STDIN_FILENO, buf, len); |
| 205 | alarm(0); |
| 206 | } |
| 207 | |
| 208 | static void lightningd_to_websocket(int lightningfd, int wsfd) |
| 209 | { |