diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-13 14:23:00 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-13 14:23:00 +0100 |
commit | 22e07e5504052efa91cf7425a1feb99f2335145f (patch) | |
tree | d2dedd32d7a401919ada6fa71de77b523a47a4a0 /src | |
parent | feff3ee1e9535e815ffda4ece472586d2d97e9ed (diff) | |
download | rspamd-22e07e5504052efa91cf7425a1feb99f2335145f.tar.gz rspamd-22e07e5504052efa91cf7425a1feb99f2335145f.zip |
[Minor] Allow to edit empty maps
Diffstat (limited to 'src')
-rw-r--r-- | src/controller.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/controller.c b/src/controller.c index 6cb5eaa62..88d1d0ed6 100644 --- a/src/controller.c +++ b/src/controller.c @@ -1047,12 +1047,18 @@ rspamd_controller_handle_get_map (struct rspamd_http_connection_entry *conn_ent, reply->date = time (NULL); reply->code = 200; - if (!rspamd_http_message_set_body_from_fd (reply, fd)) { - close (fd); - rspamd_http_message_unref (reply); - msg_err_session ("cannot read map %s: %s", bk->uri, strerror (errno)); - rspamd_controller_send_error (conn_ent, 500, "Map read error"); - return 0; + if (st.st_size > 0) { + if (!rspamd_http_message_set_body_from_fd (reply, fd)) { + close (fd); + rspamd_http_message_unref (reply); + msg_err_session ("cannot read map %s: %s", bk->uri, strerror (errno)); + rspamd_controller_send_error (conn_ent, 500, "Map read error"); + return 0; + } + } + else { + rspamd_fstring_t *empty_body = rspamd_fstring_new_init ("", 0); + rspamd_http_message_set_body_from_fstring_steal (reply, empty_body); } close (fd); |