/** @brief Sends a redirect to the web browser * @param r The request * @param url The url to redirect to * @param text The text to include in the redirect header and the manual redirect link title. NULL is acceptable */ void http_send_redirect(request *r, char *url, char *text) { char *message = NULL; char *header = NULL; char *response = NULL; /* Re-direct them to auth server */ debug(LOG_DEBUG, "Redirecting client browser to %s", url); safe_asprintf(&header, "Location: %s", url ); if(text) { safe_asprintf(&response, "307 %s\n", text ); } else { safe_asprintf(&response, "307 %s\n", "Redirecting" ); } httpdSetResponse(r, response); httpdAddHeader(r, header); free(response); free(header); safe_asprintf(&message, "Please <a href='%s'>click here</a>.", url); send_http_page(r, text ? text : "Redirection to message", message); free(message); }
/** Respond to attempted access from a preauthenticated client. * Add the client to the client list and serves the splash page. */ void http_nodogsplash_custom_request(httpd *webserver, request *r) { debug(LOG_NOTICE, "Processing custom request... %s:%s", r->request.path, r->clientAddr); httpdAddVariable(r,"test","default"); httpdAddVariable(r,"hidden","default"); httpdAddVariable(r,"survey_results",""); httpVar *var; var = httpdGetVariableByName(r,"test"); if(var && var->value) { debug(LOG_NOTICE, "Var test is : %s", var->value); } char message[] = "HIIIIII\n"; httpdSetResponse(r, "200 OK"); //httpdPrintf(r, message); sendfile(r, "post.html"); httpdDumpVariables(r); debug(LOG_NOTICE, "Custom request requested. Query: %s", r->request.query); }
void http_nodogsplash_redirect(request *r, const char url[]) { char *header; httpdSetResponse(r, "302 Found"); safe_asprintf(&header, "Location: %s",url); httpdAddHeader(r, header); httpdPrintf(r, "<html><head></head><body><a href='%s'>Click here to continue to<br>%s</a></body></html>",url,url); free(header); }
void http_nodogsplash_redirect(request *r, const char url[]) { char *header; debug(LOG_DEBUG,"Redirect client %s to %s",r->clientAddr,url); httpdSetResponse(r, "302 Found\n"); safe_asprintf(&header, "Location: http://%s",url); httpdAddHeader(r, header); httpdPrintf(r, "<html><head></head><body><a href='%s'>Click here to continue to<br>%s</a></body></html>",url,url); free(header); }
/* response handler for HTTP 405 Method Not Allowed */ void http_nodogsplash_405(request *r) { httpdSetResponse(r, "405 Method Not Allowed"); httpdPrintf(r, "405 Method Not Allowed"); }
void index_data_html(httpd *server) { httpdSetResponse(server,"501 Not Implemented"); return; }