Mercurial
comparison hg-web/main.c @ 249:c5129452493e
[deploy] Bundle Mercurial with hg-web
Co-authored-by: Copilot <[email protected]>
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Tue, 04 Aug 2026 04:16:45 -0700 |
| parents | 3007ef5fc0ed |
| children |
comparison
equal
deleted
inserted
replaced
| 248:b8b6e726964a | 249:c5129452493e |
|---|---|
| 11 #include <unistd.h> | 11 #include <unistd.h> |
| 12 | 12 |
| 13 #define HG_SERVE_HOST "127.0.0.1" | 13 #define HG_SERVE_HOST "127.0.0.1" |
| 14 #define HG_SERVE_PORT "4444" | 14 #define HG_SERVE_PORT "4444" |
| 15 #define HG_API_TIMEOUT_MS 15000 | 15 #define HG_API_TIMEOUT_MS 15000 |
| 16 #define HG_STREAM_IDLE_TIMEOUT_MS 60000 | 16 #define HG_STREAM_IDLE_TIMEOUT_MS 3600000 |
| 17 #define MAX_PATH_LENGTH 4096 | 17 #define MAX_PATH_LENGTH 4096 |
| 18 #define MAX_WIRE_QUERY_LENGTH 8192 | 18 #define MAX_WIRE_QUERY_LENGTH 8192 |
| 19 #define MAX_WIRE_HEADER_LENGTH 8192 | 19 #define MAX_WIRE_HEADER_LENGTH 8192 |
| 20 | 20 |
| 21 static const char *map_value_case_insensitive(Seobeo_Request_Entry *map, const char *key) | 21 static const char *map_value_case_insensitive(Seobeo_Request_Entry *map, const char *key) |
| 499 "application/json", | 499 "application/json", |
| 500 NULL, | 500 NULL, |
| 501 arena); | 501 arena); |
| 502 } | 502 } |
| 503 | 503 |
| 504 static int64_t monotonic_milliseconds(void) | 504 static int64 monotonic_milliseconds(void) |
| 505 { | 505 { |
| 506 struct timespec now; | 506 struct timespec now; |
| 507 clock_gettime(CLOCK_MONOTONIC, &now); | 507 clock_gettime(CLOCK_MONOTONIC, &now); |
| 508 return (int64_t)now.tv_sec * 1000 + now.tv_nsec / 1000000; | 508 return (int64)now.tv_sec * 1000 + now.tv_nsec / 1000000; |
| 509 } | 509 } |
| 510 | 510 |
| 511 static size_t find_http_header_length(const uint8 *buffer, size_t length) | 511 static size_t find_http_header_length(const uint8 *buffer, size_t length) |
| 512 { | 512 { |
| 513 if (!buffer || length < 4) | 513 if (!buffer || length < 4) |
| 662 send_proxy_error(client, 502, "Mercurial backend write failed"); | 662 send_proxy_error(client, 502, "Mercurial backend write failed"); |
| 663 return; | 663 return; |
| 664 } | 664 } |
| 665 | 665 |
| 666 boolean response_started = FALSE; | 666 boolean response_started = FALSE; |
| 667 int64_t last_progress = monotonic_milliseconds(); | 667 int64 last_progress = monotonic_milliseconds(); |
| 668 while (!response_started) | 668 while (!response_started) |
| 669 { | 669 { |
| 670 int read_result = Seobeo_Handle_Read(upstream); | 670 int read_result = Seobeo_Handle_Read(upstream); |
| 671 if (read_result == -2 || read_result < 0) | 671 if (read_result == -2 || read_result < 0) |
| 672 { | 672 { |