upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/main/tollgate_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/tollgate_api.c')
-rw-r--r--main/tollgate_api.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/main/tollgate_api.c b/main/tollgate_api.c
index b2ad647..2af04bc 100644
--- a/main/tollgate_api.c
+++ b/main/tollgate_api.c
@@ -162,17 +162,22 @@ static esp_err_t api_post_payment(httpd_req_t *req)
162 cJSON_Delete(notice); 162 cJSON_Delete(notice);
163 return ESP_OK; 163 return ESP_OK;
164 } 164 }
165 int received = httpd_req_recv(req, body, content_len); 165 int received = 0;
166 if (received <= 0) { 166 int total = 0;
167 free(body); 167 while (total < content_len) {
168 httpd_resp_set_status(req, "400 Bad Request"); 168 received = httpd_req_recv(req, body + total, content_len - total);
169 httpd_resp_set_type(req, "text/plain"); 169 if (received <= 0) {
170 httpd_resp_send(req, "bad request", 11); 170 free(body);
171 return ESP_OK; 171 httpd_resp_set_status(req, "400 Bad Request");
172 httpd_resp_set_type(req, "text/plain");
173 httpd_resp_send(req, "bad request", 11);
174 return ESP_OK;
175 }
176 total += received;
172 } 177 }
173 body[received] = '\0'; 178 body[total] = '\0';
174 179
175 ESP_LOGI(TAG, "Payment received: %d bytes", received); 180 ESP_LOGI(TAG, "Payment received: %d bytes", total);
176 181
177 cashu_token_t token; 182 cashu_token_t token;
178 esp_err_t err = cashu_decode_token(body, &token); 183 esp_err_t err = cashu_decode_token(body, &token);
@@ -330,7 +335,7 @@ esp_err_t tollgate_api_start(void)
330 config.server_port = 2121; 335 config.server_port = 2121;
331 config.ctrl_port = 32769; 336 config.ctrl_port = 32769;
332 config.max_uri_handlers = 10; 337 config.max_uri_handlers = 10;
333 config.stack_size = 16384; 338 config.stack_size = 32768;
334 339
335 esp_err_t ret = httpd_start(&s_api_server, &config); 340 esp_err_t ret = httpd_start(&s_api_server, &config);
336 if (ret != ESP_OK) { 341 if (ret != ESP_OK) {