}
}
} else if (strncmp(url, "/put", 4) == 0) {
+ char *username;
+ const char *password = "testpass";
+ const char *realm = "Blerg Post";
+
+#define OPAQUE "d29fb6db8f21a6e99903651a9f87470e"
+#define DENIED "DENIED, MOTHERFUCKER"
+#define PAGE "DERP DERP AUTHENTICATED DERP"
+
+ if (*ptr == NULL) {
+ *ptr = (void *) 1;
+
+ username = MHD_digest_auth_get_username(connection);
+ if (username == NULL) {
+ response = MHD_create_response_from_data(strlen (DENIED), DENIED, MHD_NO, MHD_NO);
+ ret = MHD_queue_auth_fail_response(connection, realm, OPAQUE, response, MHD_NO);
+ MHD_destroy_response(response);
+ return ret;
+ }
+
+ printf("username: %s\n", username);
+
+ ret = MHD_digest_auth_check(connection, realm, username, password, 300);
+ free(username);
+
+ if (ret == MHD_INVALID_NONCE || ret == MHD_NO) {
+ response = MHD_create_response_from_data(strlen (DENIED), DENIED, MHD_NO, MHD_NO);
+ ret = MHD_queue_auth_fail_response(connection, realm, OPAQUE, response,
+ (ret == MHD_INVALID_NONCE) ? MHD_YES : MHD_NO);
+ MHD_destroy_response(response);
+ return ret;
+ }
+ }
+
+ *ptr = NULL;
+
+ if (url[4] != '/')
+ return respond_404(connection);
+ ret = parse_url_info(url + 5, author, &record);
+ if ((ret & URL_INFO_AUTHOR) == 0)
+ return respond_404(connection);
+
+ response = MHD_create_response_from_data(strlen(PAGE), PAGE, MHD_NO, MHD_NO);
+ ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
+ MHD_destroy_response(response);
+ return ret;
} else {
return respond_404(connection);
}