Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implement HTTP 302 response with libmicrohttpd in C

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

like image 625
user3526827 Avatar asked May 31 '26 00:05

user3526827


1 Answers

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.

like image 111
uesp Avatar answered Jun 02 '26 16:06

uesp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!