gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] branch master updated: use 202 if JSON was requested


From: gnunet
Subject: [taler-merchant] branch master updated: use 202 if JSON was requested
Date: Sun, 16 Aug 2020 16:15:21 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 19bc7db  use 202 if JSON was requested
19bc7db is described below

commit 19bc7db44155ed9ed930586bde5f2319a8a6e673
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Aug 16 16:15:18 2020 +0200

    use 202 if JSON was requested
---
 contrib/request_payment.en.must                  | 13 +++++-
 src/backend/taler-merchant-httpd_get-orders-ID.c | 57 +++++++++++++++---------
 2 files changed, 47 insertions(+), 23 deletions(-)

diff --git a/contrib/request_payment.en.must b/contrib/request_payment.en.must
index 56063cb..048f6de 100644
--- a/contrib/request_payment.en.must
+++ b/contrib/request_payment.en.must
@@ -90,8 +90,8 @@ body {
 
 <body>
 <script>
+  let delayMs = 60000;
   let checkUrl = "{{order_status_url}}";
-  let delayMs = 500;
   function check() {
     let req = new XMLHttpRequest();
     req.onreadystatechange = function () {
@@ -106,12 +106,23 @@ body {
             console.error("could not parse response:", e);
           }
         }
+        if (req.status === 302) {
+          try {
+            document.location.reload(true);
+          } catch (e) {
+            console.error("could not parse response:", e);
+          }
+        }
         setTimeout(check, delayMs);
       }
     };
     req.onerror = function () {
       setTimeout(check, delayMs);
     }
+    req.ontimeout = function () {
+      setTimeout(check, delayMs);
+    }
+    req.timeout = delayMs;
     req.open("GET", checkUrl);
     req.send();
   }
diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c 
b/src/backend/taler-merchant-httpd_get-orders-ID.c
index 732e3cf..ba92316 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 */
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]