| 42 | } |
| 43 | |
| 44 | int TestHttpServer::callback(void *cls, MHD_Connection *connection, |
| 45 | const char *url, const char *method, |
| 46 | const char *version, const char *upload_data, |
| 47 | size_t *upload_data_size, void **con_cls) { |
| 48 | (void)upload_data; |
| 49 | (void)upload_data_size; |
| 50 | (void)url; |
| 51 | (void)method; |
| 52 | (void)version; |
| 53 | TestHttpServer *_this = static_cast<TestHttpServer *>(cls); |
| 54 | if (*con_cls == NULL) { |
| 55 | *con_cls = cls; |
| 56 | _this->headers.clear(); |
| 57 | } else { |
| 58 | MHD_get_connection_values(connection, MHD_HEADER_KIND, header_iterator, |
| 59 | cls); |
| 60 | struct MHD_Response *result = MHD_create_response_from_buffer( |
| 61 | _this->response.size(), (void *)_this->response.c_str(), |
| 62 | MHD_RESPMEM_MUST_COPY); |
| 63 | MHD_add_response_header(result, "Content-Type", "application/json"); |
| 64 | MHD_add_response_header(result, "Access-Control-Allow-Origin", "*"); |
| 65 | MHD_queue_response(connection, MHD_HTTP_OK, result); |
| 66 | MHD_destroy_response(result); |
| 67 | } |
| 68 | |
| 69 | return MHD_YES; |
| 70 | } |
| 71 | |
| 72 | int TestHttpServer::header_iterator(void *cls, MHD_ValueKind kind, |
| 73 | const char *key, const char *value) { |
no test coverage detected