From 9d59db317f2ac51c3eb058fe740bd39b3021fbcd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Tue, 24 May 2016 16:15:08 +0200 Subject: [PATCH] Improves behaviour of afb_req_get MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The implementations of afb_req_get were not the same for HTTP and WebSocket when the argument wasn't set. Change-Id: I2f09376f597ee75a50b06423a19823040a9352e6 Signed-off-by: José Bollo --- src/afb-hreq.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/afb-hreq.c b/src/afb-hreq.c index 8c5110d9..4239670d 100644 --- a/src/afb-hreq.c +++ b/src/afb-hreq.c @@ -611,6 +611,7 @@ struct afb_req afb_hreq_to_req(struct afb_hreq *hreq) static struct afb_arg req_get(struct afb_hreq *hreq, const char *name) { + const char *value; struct hreq_data *hdat = get_data(hreq, name, 0); if (hdat) return (struct afb_arg){ @@ -618,10 +619,11 @@ static struct afb_arg req_get(struct afb_hreq *hreq, const char *name) .value = hdat->value, .path = hdat->path }; - + + value = MHD_lookup_connection_value(hreq->connection, MHD_GET_ARGUMENT_KIND, name); return (struct afb_arg){ - .name = name, - .value = MHD_lookup_connection_value(hreq->connection, MHD_GET_ARGUMENT_KIND, name), + .name = value == NULL ? NULL : name, + .value = value, .path = NULL }; } -- 2.16.6