diff options
author | José Bollo <jose.bollo@iot.bzh> | 2016-04-08 17:31:49 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2016-04-08 17:31:49 +0200 |
commit | 2c5dc2d88b8d2434934315fb285f4efade040543 (patch) | |
tree | 8149c52dd16e09bbc14df6d4289b596857412f46 | |
parent | fcef933b69ccc363ad10d9f7308f02c5dc474ff6 (diff) |
simplification
Change-Id: I02a107da2908f62dd10b09c3d765a0e0dd48983e
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r-- | src/afb-hsrv.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/afb-hsrv.c b/src/afb-hsrv.c index c58295a4..2c303d3c 100644 --- a/src/afb-hsrv.c +++ b/src/afb-hsrv.c @@ -65,19 +65,8 @@ struct afb_hsrv { static void reply_error(struct MHD_Connection *connection, unsigned int status) { - char *buffer; - int length; - struct MHD_Response *response; - - length = asprintf(&buffer, "<html><body>error %u</body></html>", status); - if (length > 0) - response = MHD_create_response_from_buffer((unsigned)length, buffer, MHD_RESPMEM_MUST_FREE); - else { - buffer = "<html><body>error</body></html>"; - response = MHD_create_response_from_buffer(strlen(buffer), buffer, MHD_RESPMEM_PERSISTENT); - } - if (!MHD_queue_response(connection, status, response)) - fprintf(stderr, "Failed to reply error code %u", status); + struct MHD_Response *response = MHD_create_response_from_buffer(0, NULL, MHD_RESPMEM_PERSISTENT); + MHD_queue_response(connection, status, response); MHD_destroy_response(response); } |