I'm wondering how to implement a 302 redirect with libmicrohttpd in C. I know the response should be MHD_HTTP_FOUND but I am not sure how to pass the Location:... to be redirected. I've searched and haven't found much on this; is it possible?
Thank you
From the response headers tutorial you'll need to create a response object and add the location header like:
struct MHD_Response *response;
// Create response object
MHD_add_response_header (response, "Location", "http://somesite.com/page.html");
MHD_queue_response (connection, MHD_HTTP_OK, response);
Also see the libmicrohttpd response header documentation for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With