Mercurial
comparison seobeo/tests/seobeo_http_framing_test.c @ 279:b3b547563ec7
Add Google connector service and agent wiki
Implement the C/Seobeo Google Drive and Gmail connector with encrypted OAuth storage, Zenbu authentication, browser testing, AI tool discovery, chunked HTTP decoding, and Bazel coverage. Consolidate repository guidance into progressive wiki documentation and enforce arena-first allocation for new first-party C code.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 84c338fd-0939-4bb3-b7f3-1062eb213e5d
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Mon, 17 Aug 2026 22:22:36 -0700 |
| parents | ce7f4400c2de |
| children |
comparison
equal
deleted
inserted
replaced
| 278:8d560f50ed4c | 279:b3b547563ec7 |
|---|---|
| 10 } Framing_Server; | 10 } Framing_Server; |
| 11 | 11 |
| 12 static void *serve_close_delimited_response(void *argument) | 12 static void *serve_close_delimited_response(void *argument) |
| 13 { | 13 { |
| 14 Framing_Server *server = argument; | 14 Framing_Server *server = argument; |
| 15 int client = accept(server->listener, NULL, NULL); | 15 for (int response_index = 0; response_index < 2; response_index++) { |
| 16 if (client >= 0) { | 16 int client = accept(server->listener, NULL, NULL); |
| 17 if (client < 0) | |
| 18 continue; | |
| 17 char request[1024]; | 19 char request[1024]; |
| 18 (void)read(client, request, sizeof(request)); | 20 (void)read(client, request, sizeof(request)); |
| 19 const char response[] = | 21 if (response_index == 0) { |
| 20 "HTTP/1.1 200 OK\r\n" | 22 const char response[] = |
| 21 "Content-Type: text/plain\r\n" | 23 "HTTP/1.1 200 OK\r\n" |
| 22 "Connection: close\r\n" | 24 "Content-Type: text/plain\r\n" |
| 23 "\r\n" | 25 "Connection: close\r\n" |
| 24 "buffered-body"; | 26 "\r\n" |
| 25 (void)write(client, response, sizeof(response) - 1); | 27 "buffered-body"; |
| 28 (void)write(client, response, sizeof(response) - 1); | |
| 29 } else { | |
| 30 const char response[] = | |
| 31 "HTTP/1.1 200 OK\r\n" | |
| 32 "Content-Type: application/json\r\n" | |
| 33 "Transfer-Encoding: chunked\r\n" | |
| 34 "Connection: close\r\n" | |
| 35 "\r\n" | |
| 36 "7;sample=yes\r\n" | |
| 37 "{\"ok\":t\r\n" | |
| 38 "4\r\n" | |
| 39 "rue}\r\n" | |
| 40 "0\r\n" | |
| 41 "X-Trailer: ignored\r\n" | |
| 42 "\r\n"; | |
| 43 (void)write(client, response, sizeof(response) - 1); | |
| 44 } | |
| 26 close(client); | 45 close(client); |
| 27 } | 46 } |
| 28 return NULL; | 47 return NULL; |
| 29 } | 48 } |
| 30 | 49 |
| 57 close(listener); | 76 close(listener); |
| 58 return 1; | 77 return 1; |
| 59 } | 78 } |
| 60 | 79 |
| 61 char url[128]; | 80 char url[128]; |
| 62 snprintf(url, sizeof(url), "http://127.0.0.1:%u/", ntohs(address.sin_port)); | 81 snprintf( |
| 82 url, sizeof(url), "http://127.0.0.1:%u/close", | |
| 83 ntohs(address.sin_port)); | |
| 63 Seobeo_Client_Request *request = Seobeo_Client_Request_Create(url); | 84 Seobeo_Client_Request *request = Seobeo_Client_Request_Create(url); |
| 64 Seobeo_Client_Request_Set_Timeout_Milliseconds(request, 1000); | 85 Seobeo_Client_Request_Set_Timeout_Milliseconds(request, 1000); |
| 65 Seobeo_Client_Response *response = Seobeo_Client_Request_Execute(request); | 86 Seobeo_Client_Response *response = Seobeo_Client_Request_Execute(request); |
| 66 | 87 |
| 67 int failed = !response || | 88 int failed = !response || |
| 71 if (failed) | 92 if (failed) |
| 72 fprintf(stderr, "Close-delimited response body was not preserved\n"); | 93 fprintf(stderr, "Close-delimited response body was not preserved\n"); |
| 73 | 94 |
| 74 Seobeo_Client_Response_Destroy(response); | 95 Seobeo_Client_Response_Destroy(response); |
| 75 Seobeo_Client_Request_Destroy(request); | 96 Seobeo_Client_Request_Destroy(request); |
| 97 | |
| 98 snprintf( | |
| 99 url, sizeof(url), "http://127.0.0.1:%u/chunked", | |
| 100 ntohs(address.sin_port)); | |
| 101 request = Seobeo_Client_Request_Create(url); | |
| 102 Seobeo_Client_Request_Set_Timeout_Milliseconds(request, 1000); | |
| 103 response = Seobeo_Client_Request_Execute(request); | |
| 104 int chunked_failed = !response || | |
| 105 response->status_code != 200 || | |
| 106 response->body_length != strlen("{\"ok\":true}") || | |
| 107 memcmp(response->body, "{\"ok\":true}", strlen("{\"ok\":true}")) != 0; | |
| 108 if (chunked_failed) | |
| 109 fprintf(stderr, "Chunked response body was not decoded\n"); | |
| 110 failed = failed || chunked_failed; | |
| 111 | |
| 112 Seobeo_Client_Response_Destroy(response); | |
| 113 Seobeo_Client_Request_Destroy(request); | |
| 76 pthread_join(thread, NULL); | 114 pthread_join(thread, NULL); |
| 77 close(listener); | 115 close(listener); |
| 78 return failed; | 116 return failed; |
| 79 } | 117 } |