aboutsummaryrefslogtreecommitdiff
path: root/src/sync/sync-httpd_mhd.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-11-24 17:32:30 +0100
committerChristian Grothoff <christian@grothoff.org>2019-11-24 17:32:30 +0100
commitd6108a63b016ebe8410049ca1292b0d7fef73291 (patch)
treebd5fd3b42330af33fe4b1749948bb6acbdcb432d /src/sync/sync-httpd_mhd.c
parente462042a4d7ce91c0731871f014b78e6906b4171 (diff)
downloadsync-d6108a63b016ebe8410049ca1292b0d7fef73291.tar.gz
sync-d6108a63b016ebe8410049ca1292b0d7fef73291.tar.bz2
sync-d6108a63b016ebe8410049ca1292b0d7fef73291.zip
use libtalermhd in sync
Diffstat (limited to 'src/sync/sync-httpd_mhd.c')
-rw-r--r--src/sync/sync-httpd_mhd.c96
1 files changed, 14 insertions, 82 deletions
diff --git a/src/sync/sync-httpd_mhd.c b/src/sync/sync-httpd_mhd.c
index 077105e..75f2a63 100644
--- a/src/sync/sync-httpd_mhd.c
+++ b/src/sync/sync-httpd_mhd.c
@@ -25,7 +25,6 @@
#include "platform.h"
#include <jansson.h>
#include "sync-httpd_mhd.h"
-#include "sync-httpd_responses.h"
/**
@@ -46,29 +45,16 @@ SH_MHD_handler_static_response (struct SH_RequestHandler *rh,
const char *upload_data,
size_t *upload_data_size)
{
- struct MHD_Response *response;
- int ret;
-
+ (void) connection_cls;
+ (void) upload_data;
+ (void) upload_data_size;
if (0 == rh->data_size)
rh->data_size = strlen ((const char *) rh->data);
- response = MHD_create_response_from_buffer (rh->data_size,
- (void *) rh->data,
- MHD_RESPMEM_PERSISTENT);
- if (NULL == response)
- {
- GNUNET_break (0);
- return MHD_NO;
- }
- SH_RESPONSE_add_global_headers (response);
- if (NULL != rh->mime_type)
- (void) MHD_add_response_header (response,
- MHD_HTTP_HEADER_CONTENT_TYPE,
- rh->mime_type);
- ret = MHD_queue_response (connection,
- rh->response_code,
- response);
- MHD_destroy_response (response);
- return ret;
+ return TALER_MHD_reply_static (connection,
+ rh->response_code,
+ rh->mime_type,
+ (void *) rh->data,
+ rh->data_size);
}
@@ -90,66 +76,12 @@ SH_MHD_handler_agpl_redirect (struct SH_RequestHandler *rh,
const char *upload_data,
size_t *upload_data_size)
{
- const char *agpl =
- "This server is licensed under the Affero GPL. You will now be redirected to the source code.";
- struct MHD_Response *response;
- int ret;
-
- response = MHD_create_response_from_buffer (strlen (agpl),
- (void *) agpl,
- MHD_RESPMEM_PERSISTENT);
- if (NULL == response)
- {
- GNUNET_break (0);
- return MHD_NO;
- }
- SH_RESPONSE_add_global_headers (response);
- if (NULL != rh->mime_type)
- (void) MHD_add_response_header (response,
- MHD_HTTP_HEADER_CONTENT_TYPE,
- rh->mime_type);
- if (MHD_NO ==
- MHD_add_response_header (response,
- MHD_HTTP_HEADER_LOCATION,
- "http://www.git.taler.net/sync.git"))
- {
- GNUNET_break (0);
- ret = MHD_NO;
- }
- else
- {
- ret = MHD_queue_response (connection,
- rh->response_code,
- response);
- }
- MHD_destroy_response (response);
- return ret;
-}
-
-
-/**
- * Function to call to handle the request by building a JSON
- * reply with an error message from @a rh.
- *
- * @param rh context of the handler
- * @param connection the MHD connection to handle
- * @param[in,out] connection_cls the connection's closure (can be updated)
- * @param upload_data upload data
- * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
- * @return MHD result code
- */
-int
-SH_MHD_handler_send_json_pack_error (struct SH_RequestHandler *rh,
- struct MHD_Connection *connection,
- void **connection_cls,
- const char *upload_data,
- size_t *upload_data_size)
-{
- return SH_RESPONSE_reply_json_pack (connection,
- rh->response_code,
- "{s:s}",
- "error",
- rh->data);
+ (void) rh;
+ (void) connection_cls;
+ (void) upload_data;
+ (void) upload_data_size;
+ return TALER_MHD_reply_agpl (connection,
+ "http://www.git.taler.net/sync.git");
}