34 #define _BASIC_BASE "Basic " 52 const char *separator;
61 (0 != strncmp (header,
69 MHD_DLOG (connection->
daemon,
70 _(
"Error decoding basic authentication\n"));
75 if (
NULL == (separator = strchr (decode,
79 MHD_DLOG(connection->
daemon,
80 _(
"Basic authentication doesn't contain ':' separator\n"));
85 if (
NULL == (user = strdup (decode)))
90 user[separator - decode] =
'\0';
93 *password = strdup (separator + 1);
94 if (
NULL == *password)
97 MHD_DLOG(connection->
daemon,
98 _(
"Failed to allocate memory for password\n"));
129 size_t hlen = strlen(realm) + strlen(
"Basic realm=\"\"") + 1;
132 header = (
char *) malloc(hlen);
136 MHD_DLOG(connection->
daemon,
137 "Failed to allocate memory for auth header\n");
141 res = MHD_snprintf_ (header,
143 "Basic realm=\"%s\"",
145 if (res > 0 && (
size_t)res < hlen)
160 MHD_DLOG (connection->
daemon,
161 _(
"Failed to add Basic auth header\n"));
Header for platform missing functions.
_MHD_EXTERN int MHD_add_response_header(struct MHD_Response *response, const char *header, const char *content)
_MHD_EXTERN int MHD_queue_basic_auth_fail_response(struct MHD_Connection *connection, const char *realm, struct MHD_Response *response)
struct MHD_Daemon * daemon
_MHD_EXTERN char * MHD_basic_auth_get_username_password(struct MHD_Connection *connection, char **password)
internal shared structures
#define MHD_STATICSTR_LEN_(macro)
_MHD_EXTERN int MHD_queue_response(struct MHD_Connection *connection, unsigned int status_code, struct MHD_Response *response)
#define MHD_HTTP_UNAUTHORIZED
char * BASE64Decode(const char *src)
_MHD_EXTERN int MHD_lookup_connection_value_n(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, size_t key_size, const char **value_ptr, size_t *value_size_ptr)
limits values definitions