diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-08-16 16:15:18 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-08-16 16:15:18 +0200 |
commit | 19bc7db44155ed9ed930586bde5f2319a8a6e673 (patch) | |
tree | 3480c5fec0f778c03f409a68c4d852cba04e3bb1 /src | |
parent | e53ad1e718cd6b5acab5672a8dbb2998477e4f86 (diff) | |
download | merchant-19bc7db44155ed9ed930586bde5f2319a8a6e673.tar.gz merchant-19bc7db44155ed9ed930586bde5f2319a8a6e673.tar.bz2 merchant-19bc7db44155ed9ed930586bde5f2319a8a6e673.zip |
use 202 if JSON was requested
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/taler-merchant-httpd_get-orders-ID.c | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c index 732e3cfc..ba92316c 100644 --- a/src/backend/taler-merchant-httpd_get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_get-orders-ID.c @@ -1157,30 +1157,43 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, if ( (! token_match) && (! contract_match) ) { - /* Contract was claimed (maybe by another device), so this client - cannot get the status information. Redirect to fulfillment page, - where the client may be able to pickup a fresh order -- or might - be able authenticate via session ID */ - struct MHD_Response *reply; - MHD_RESULT ret; - - reply = MHD_create_response_from_buffer (0, - NULL, - MHD_RESPMEM_PERSISTENT); - if (NULL == reply) + if (god->generate_html) { - GNUNET_break (0); - return MHD_NO; + /* Contract was claimed (maybe by another device), so this client + cannot get the status information. Redirect to fulfillment page, + where the client may be able to pickup a fresh order -- or might + be able authenticate via session ID */ + struct MHD_Response *reply; + MHD_RESULT ret; + + reply = MHD_create_response_from_buffer (0, + NULL, + MHD_RESPMEM_PERSISTENT); + if (NULL == reply) + { + GNUNET_break (0); + return MHD_NO; + } + GNUNET_break (MHD_YES == + MHD_add_response_header (reply, + MHD_HTTP_HEADER_LOCATION, + god->fulfillment_url)); + ret = MHD_queue_response (connection, + MHD_HTTP_FOUND, + reply); + MHD_destroy_response (reply); + return ret; + } + else + { + /* Need to generate JSON reply */ + return TALER_MHD_reply_json_pack ( + connection, + MHD_HTTP_ACCEPTED, + "{s:s}", + "fulfillment_url", + god->fulfillment_url); } - GNUNET_break (MHD_YES == - MHD_add_response_header (reply, - MHD_HTTP_HEADER_LOCATION, - god->fulfillment_url)); - ret = MHD_queue_response (connection, - MHD_HTTP_FOUND, - reply); - MHD_destroy_response (reply); - return ret; } } /* end of first-time initialization / sanity checks */ |