34 #include <microhttpd.h> 39 #define DATE_2822_LEN 100 44 #define EXPIRES_LENGTH 100 49 #define UTF8_ERROR_PAGE(location) \ 51 "<head><title>Invalid request</title></head>" \ 52 "<body>The request contained invalid UTF-8 in " location ".</body>" \ 58 #define SID_COOKIE_NAME "GSAD_SID" 60 #define REMOVE_SID "0" 65 #define NOT_FOUND_TITLE "Invalid request" 70 #define NOT_FOUND_MESSAGE "The requested page or file does not exist." 75 #define ERROR_PAGE "<html><body>HTTP Method not supported</body></html>" 80 #define BAD_REQUEST_PAGE "<html><body>Bad request.</body></html>" 85 #define SERVER_ERROR \ 86 "<html><body>An internal server error has occurred.</body></html>" 93 #define MAX_HOST_LEN 1000 95 #define LOGIN_URL "/login" 96 #define LOGOUT_URL "/logout" 101 #define POST_BUFFER_SIZE 500000 107 #ifndef MHD_HTTP_NOT_ACCEPTABLE 108 #define MHD_HTTP_NOT_ACCEPTABLE MHD_HTTP_METHOD_NOT_ACCEPTABLE 114 #define MAX_FILE_NAME_SIZE 128 175 int http_status_code,
181 const char *content_disposition,
size_t content_length);
211 serve_post (
void *coninfo_cls,
enum MHD_ValueKind kind,
const char *key,
213 const char *transfer_encoding,
const char *data, uint64_t off,
232 const char *client_address);
236 const char *chunk_data,
int chunk_size,
int chunk_offset);
content_type_t guess_content_type(const gchar *path)
Guess a content type from a file extension.
GSAD credentials handling.
Structure of credential related information.
Headers for Response Data struct.
params_t * params
Request parameters.
int attach_sid(http_response_t *response, const char *sid)
Attach SID cookie to a response, resetting "expire" arg.
int handler_send_not_found(http_connection_t *connection, const gchar *url)
Send a 404 response for a request.
int remove_sid(http_response_t *response)
Attach expired SID cookie to response.
void add_guest_chart_content_security_headers(http_response_t *response)
Add guest chart content security headers to a MHD response.
int handler_create_response(http_connection_t *connection, gchar *data, cmd_response_data_t *response_data, const gchar *sid)
Create and send a response.
int connectiontype
1=POST, 2=GET.
int send_redirect_to_uri(http_connection_t *connection, const char *uri, const gchar *sid)
Sends a HTTP redirection to an uri.
http_response_t * file_content_response(http_connection_t *connection, const char *url, const char *path, cmd_response_data_t *response_data)
Create a response to serve a file from a path.
struct MHD_Connection http_connection_t
int send_response(http_connection_t *connection, const char *content, int status_code, const gchar *sid, content_type_t content_type, const char *content_disposition, size_t content_length)
Sends a HTTP response.
int exec_gmp_get(http_connection_t *connection, gsad_connection_info_t *con_info, credentials_t *credentials)
Response information for commands.
enum authentication_reason authentication_reason_t
int params_append_mhd(params_t *params, const char *name, const char *filename, const char *chunk_data, int chunk_size, int chunk_offset)
char * gsad_message(credentials_t *, const char *, const char *, int, const char *, cmd_response_data_t *)
Handles fatal errors.
gchar * redirect
Redirect URL.
authentication_reason
Content types.
enum content_type content_type_t
int handler_send_response(http_connection_t *connection, http_response_t *response, cmd_response_data_t *response_data, const gchar *sid)
Send response for handle_request.
gchar * reconstruct_url(http_connection_t *connection, const char *url)
Reconstruct the URL for a connection.
struct MHD_PostProcessor * postprocessor
POST processor.
int exec_gmp_post(http_connection_t *connection, gsad_connection_info_t *con_info, const char *client_address)
char * language
Language code e.g. en.
int get_client_address(http_connection_t *conn, char *client_address)
Get the client's address.
void add_security_headers(http_response_t *response)
Add security headers to a MHD response.
struct gsad_connection_info gsad_connection_info_t
Connection information.
struct MHD_Response http_response_t
Headers for content type.
int serve_post(void *coninfo_cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size)
Serves part of a POST request.
void add_forbid_caching_headers(http_response_t *response)
Add header to forbid caching to a HTTP response.
char * cookie
Value of SID cookie param.
void add_cors_headers(http_response_t *response)
int handler_send_reauthentication(http_connection_t *connection, int http_status_code, authentication_reason_t reason)
Allow for reauthentication of a user.
void gsad_add_content_type_header(http_response_t *response, content_type_t *ct)
Adds content-type header fields to a response.
content_type
Content types.
int attach_remove_sid(http_response_t *response, const gchar *sid)