34 #define _BASIC_BASE "Basic " 52 const char *separator;
58 (0 != strncmp (header,
66 MHD_DLOG (connection->
daemon,
67 _(
"Error decoding basic authentication\n"));
72 if (
NULL == (separator = strchr (decode,
76 MHD_DLOG(connection->
daemon,
77 _(
"Basic authentication doesn't contain ':' separator\n"));
82 if (
NULL == (user = strdup (decode)))
87 user[separator - decode] =
'\0';
90 *password = strdup (separator + 1);
91 if (
NULL == *password)
94 MHD_DLOG(connection->
daemon,
95 _(
"Failed to allocate memory for password\n"));
126 size_t hlen = strlen(realm) + strlen(
"Basic realm=\"\"") + 1;
129 header = (
char *) malloc(hlen);
133 MHD_DLOG(connection->
daemon,
134 "Failed to allocate memory for auth header\n");
138 res = MHD_snprintf_ (header,
140 "Basic realm=\"%s\"",
142 if (res > 0 && (
size_t)res < hlen)
157 MHD_DLOG (connection->
daemon,
158 _(
"Failed to add Basic auth header\n"));
_MHD_EXTERN const char * MHD_lookup_connection_value(struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key)
_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)
Header for platform missing functions.
struct MHD_Daemon * daemon
#define MHD_STATICSTR_LEN_(macro)
_MHD_EXTERN char * MHD_basic_auth_get_username_password(struct MHD_Connection *connection, char **password)
limits values definitions
internal shared structures
_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)