| 818 | } |
| 819 | |
| 820 | static int ui_adr_post_request(th_server_t *ts, const char *project, const char *content, |
| 821 | char *resp, size_t respsz) { |
| 822 | char body[2048]; |
| 823 | int body_len = |
| 824 | snprintf(body, sizeof(body), "{\"project\":\"%s\",\"content\":\"%s\"}", project, content); |
| 825 | if (body_len < 0 || (size_t)body_len >= sizeof(body)) |
| 826 | return 0; |
| 827 | |
| 828 | char req[2304]; |
| 829 | int req_len = snprintf(req, sizeof(req), |
| 830 | "POST /api/adr HTTP/1.1\r\n" |
| 831 | "Content-Type: application/json\r\n" |
| 832 | "Content-Length: %d\r\n\r\n%s", |
| 833 | body_len, body); |
| 834 | if (req_len < 0 || (size_t)req_len >= sizeof(req)) |
| 835 | return 0; |
| 836 | return th_http(cbm_http_server_port(ts->srv), req, resp, respsz); |
| 837 | } |
| 838 | |
| 839 | static int ui_adr_get_request(th_server_t *ts, const char *project, char *resp, size_t respsz) { |
| 840 | char req[512]; |
no test coverage detected