-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi,
I am trying to send a post request to MHD_Daemon and then access the post data from the request in MHD_AccessHandlerCallback function which MHD_Daemon calls when it receives the request. For some reason, however, I am unable to access the post data from the callback function. Do I always need to use MHD_PostProcessor to process the post data or can I do without it? Here is my code: void test_send_response_helper (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **con_cls) { int ret_val; // print url and upload_data printf ("URL: %s\nDATA: %s\n", url, upload_data); } void test_send_response () { long int ssl_port = 443; struct MHD_Daemon *ssl_daemon; ssl_daemon = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION, ssl_port, NULL, NULL, &test_send_response_helper, NULL, MHD_OPTION_NOTIFY_COMPLETED, request_completed, NULL, MHD_OPTION_END ); CURL *curl; CURLcode res; /* Initialize curl. */ curl_global_init(CURL_GLOBAL_ALL); curl = curl_easy_init(); /* Set curl options. */ if (curl) { char* data_to_send = "field_name=value"; /* We want to send a test request to the daemon. */ curl_easy_setopt(curl, CURLOPT_URL, "http://localhost/target/www.wikipedia.org+443"); curl_easy_setopt(curl, CURLOPT_PORT, ssl_port); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data_to_send); curl_easy_setopt(curl, CURLOPT_POST, 1L); /* Make the curl request. */ res = curl_easy_perform(curl); } ... } When I call test_send_response(), I get the following output from the printf statement: $ ./test URL: /target/www.wikipedia.org 443 DATA: (null) I would like to retrieve whatever is passed as data_to_send with curl, but instead I am getting (null). How can I access the data? Am I wrong to expect the post data curl sends to be stored in the upload_data variable in test_send_response_helper? What am I doing wrong? Thanks, Martin -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJPlxA9AAoJEOzT5+ruTKvq6o4H/1tD8CEm6paZn10aVfMMRJpw lrUCxVFZTV/m/yrW3tGc/axr6IUxZmsl9FxVnFiGrKyVURQx7XSCHGiNfNMS1uZU A0xfUfd7vR415S/Y9BcJT6CnKUsu+k+fuxnhUd+xjJNAPU5TsqnYvzMYTKl9Fo+a PtwGBAjfIPwtsWkwgUruL7JYYh+4EwWUGPqyhgZe3nbVVEYH7EDsvWpJ0pc0ZIpb GSr1uHKPrO4txfOg6qXHcF5f39JtzvN8UURl3aCZem6OP923uDQFCZhTQYJmjKjc ZS+0O4wDGLJxt2tMVONYJ0ukdN3ubhjAwWXAJnX0BizJ6YAf6pd8iI/sH0tun1E= =tOvi -----END PGP SIGNATURE-----