gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-survey] branch master updated: forging response head


From: gnunet
Subject: [GNUnet-SVN] [taler-survey] branch master updated: forging response headers
Date: Tue, 21 Nov 2017 17:13:04 +0100

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

marcello pushed a commit to branch master
in repository survey.

The following commit(s) were added to refs/heads/master by this push:
     new 054d9d0  forging response headers
054d9d0 is described below

commit 054d9d0f6eaca6c90cc576d568066464d0040003
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Nov 21 17:12:48 2017 +0100

    forging response headers
---
 talersurvey/survey/survey.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/talersurvey/survey/survey.py b/talersurvey/survey/survey.py
index 2ea7ac2..8697ddf 100644
--- a/talersurvey/survey/survey.py
+++ b/talersurvey/survey/survey.py
@@ -19,6 +19,7 @@ import os
 import base64
 import requests
 import logging
+from .amount import Amount
 from talersurvey.talerconfig import TalerConfig
 from urllib.parse import urljoin
 
@@ -72,13 +73,21 @@ def index():
 @app.route("/survey", methods=["GET", "POST"])
 def survey():
     success = False
+    amount = Amount(CURRENCY, 1)
     if flask.request.method == "POST":
         r = requests.post(urljoin(BACKEND_URL, 'tip-authorize'),
-                          json=dict(amount=dict(value=1, fraction=0, 
currency=CURRENCY),
+                          json=dict(amount=amount.dump(),
                                     instance="default",
                                     justification="Payment methods survey"))
         if 200 != r.status_code:
             return backend_error(r)
         else:
             success = True
-    return flask.render_template("templates/index.html", success=success)
+
+    response = 
flask.make_response(flask.render_template("templates/index.html", 
success=success), 402)
+    response.headers["X-Taler-Tipping-Url"] = "%s/%s?id=%s" % 
(flask.request.script_root, "pick", r.json().get("tip_id"))
+    response.headers["X-Taler-Tipping-Exchange"] = r.json().get("exchange_uri")
+    response.headers["X-Taler-Tipping-Amount"] = amount.stringify(2)
+    response.headers["X-Taler-Tipping-Deadline"] = r.json().get("expiration")
+
+    return response

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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