MCPcopy Create free account
hub / github.com/cinemast/libjson-rpc-cpp / callback

Method callback

src/test/testhttpserver.cpp:40–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.80
c_strMethod · 0.80

Tested by

no test coverage detected