[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-merchant] branch master updated: returning all the h
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-merchant] branch master updated: returning all the headers that the mitm got from the exchange. This copies the "server" headers though. Wise? |
Date: |
Fri, 28 Apr 2017 18:52:28 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository merchant.
The following commit(s) were added to refs/heads/master by this push:
new 0217dad returning all the headers that the mitm got from the
exchange. This copies the "server" headers though. Wise?
0217dad is described below
commit 0217dadb0668f1f17d7b674181cc521a063dfca6
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri Apr 28 18:50:51 2017 +0200
returning all the headers that the mitm got from
the exchange. This copies the "server" headers though.
Wise?
---
src/mitm/talermerchantmitm/mitm.py | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/src/mitm/talermerchantmitm/mitm.py
b/src/mitm/talermerchantmitm/mitm.py
index 9c92aba..df33e24 100644
--- a/src/mitm/talermerchantmitm/mitm.py
+++ b/src/mitm/talermerchantmitm/mitm.py
@@ -17,7 +17,8 @@
from flask import (request,
Flask,
- jsonify)
+ jsonify,
+ make_response)
import requests
from urllib.parse import (urljoin,
urlencode,
@@ -46,6 +47,12 @@ def track_transaction(resp):
def track_transfer(resp):
return resp
+def fallback(resp):
+ if "application/json" == resp.headers["Content-Type"]:
+ return make_response(jsonify(resp.json()))
+ else:
+ return make_response(resp.text)
+
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>', methods=["GET", "POST"])
def all(path):
@@ -59,14 +66,13 @@ def all(path):
r = requests.post(urljoin(url, path), json=body)
else:
r = requests.get(urljoin(url, path), json=body)
- resp = dict()
- if "application/json" == r.headers["Content-Type"]:
- resp = r.json()
dispatcher = {
"track_transaction": track_transaction,
"track_transfer": track_transfer
}
func = dispatcher.get(request.headers.get("X-Taler-Mitm"),
- lambda x: x)
-
- return jsonify(func(resp)), r.status_code
+ fallback)
+ response = func(r)
+ for key, value in r.headers.items():
+ response.headers[key] = value
+ return response, r.status_code
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-merchant] branch master updated: returning all the headers that the mitm got from the exchange. This copies the "server" headers though. Wise?,
gnunet <=