summaryrefslogtreecommitdiff
path: root/src/journal/journal-remote.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-03-16 20:05:50 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-03-17 01:55:48 -0400
commite7216d112aff3ba4ce196db95b86d77d5a1b234e (patch)
tree26b7e09325919ebff2cb06396250e3c4e7ea2982 /src/journal/journal-remote.c
parentcc64d0175a3c2c974709e9962c00fbe04d74c43f (diff)
microhttpd-util: use static buffer for static messages
Most of the messages we send do not require a allocating and freeing a buffer, to optimize this by using const strings. Also, rename respond_error to mhd_respond*, since it is used not only for errors. Make use of information from printf to avoid one extra call to strlen.
Diffstat (limited to 'src/journal/journal-remote.c')
-rw-r--r--src/journal/journal-remote.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/journal/journal-remote.c b/src/journal/journal-remote.c
index 1a1ca2c480..78401839d5 100644
--- a/src/journal/journal-remote.c
+++ b/src/journal/journal-remote.c
@@ -411,7 +411,7 @@ static int process_http_upload(
if (r < 0) {
log_error("Failed to store received data of size %zu: %s",
*upload_data_size, strerror(-r));
- return respond_oom_internal(connection);
+ return mhd_respond_oom(connection);
}
*upload_data_size = 0;
} else
@@ -425,8 +425,8 @@ static int process_http_upload(
break;
else if (r < 0) {
log_warning("Failed to process data for connection %p", connection);
- return respond_error(connection, MHD_HTTP_UNPROCESSABLE_ENTITY,
- "Processing failed: %s", strerror(-r));
+ return mhd_respondf(connection, MHD_HTTP_UNPROCESSABLE_ENTITY,
+ "Processing failed: %s", strerror(-r));
}
}
@@ -437,11 +437,11 @@ static int process_http_upload(
if (source_non_empty(source)) {
log_warning("EOF reached with incomplete data");
- return respond_error(connection, MHD_HTTP_EXPECTATION_FAILED,
- "Trailing data not processed.");
+ return mhd_respond(connection, MHD_HTTP_EXPECTATION_FAILED,
+ "Trailing data not processed.");
}
- return respond_error(connection, MHD_HTTP_ACCEPTED, "OK.\n");
+ return mhd_respond(connection, MHD_HTTP_ACCEPTED, "OK.\n");
};
static int request_handler(
@@ -470,19 +470,19 @@ static int request_handler(
*connection_cls);
if (!streq(method, "POST"))
- return respond_error(connection, MHD_HTTP_METHOD_NOT_ACCEPTABLE,
- "Unsupported method.\n");
+ return mhd_respond(connection, MHD_HTTP_METHOD_NOT_ACCEPTABLE,
+ "Unsupported method.\n");
if (!streq(url, "/upload"))
- return respond_error(connection, MHD_HTTP_NOT_FOUND,
- "Not found.\n");
+ return mhd_respond(connection, MHD_HTTP_NOT_FOUND,
+ "Not found.\n");
header = MHD_lookup_connection_value(connection,
MHD_HEADER_KIND, "Content-Type");
if (!header || !streq(header, "application/vnd.fdo.journal"))
- return respond_error(connection, MHD_HTTP_UNSUPPORTED_MEDIA_TYPE,
- "Content-Type: application/vnd.fdo.journal"
- " is required.\n");
+ return mhd_respond(connection, MHD_HTTP_UNSUPPORTED_MEDIA_TYPE,
+ "Content-Type: application/vnd.fdo.journal"
+ " is required.\n");
if (trust_pem) {
r = check_permissions(connection, &code);