|
26 | 26 | import random |
27 | 27 | import errno |
28 | 28 | import socket |
29 | | -import ssl |
| 29 | +import ssl |
| 30 | +from urllib.parse import urlsplit |
30 | 31 |
|
31 | 32 | class GatewayRequest: |
32 | 33 |
|
@@ -86,6 +87,8 @@ class GatewayRequest: |
86 | 87 |
|
87 | 88 | GATEWAY_CONNECT_TIMEOUT = "gatewayConnectTimeout" |
88 | 89 | GATEWAY_SERVER = "gatewayServer" |
| 90 | + GATEWAY_SERVLET = "gatewayServlet" |
| 91 | + GATEWAY_PORTNO = "gatewayPortNo" |
89 | 92 | GATEWAY_READ_TIMEOUT = "gatewayReadTimeout" |
90 | 93 | GENERATE_POSTBACK = "generatePostback" |
91 | 94 |
|
@@ -618,8 +621,8 @@ def SendTransaction(self, serverName, request, response): |
618 | 621 | # |
619 | 622 | # Gather overrides for transaction. |
620 | 623 | # |
621 | | - urlServlet = request.Get("gatewayServlet") |
622 | | - urlPortNo = request.Get("portNo") |
| 624 | + urlServlet = request.Get(GatewayRequest.GATEWAY_SERVLET) |
| 625 | + urlPortNo = request.Get(GatewayRequest.GATEWAY_PORTNO) |
623 | 626 |
|
624 | 627 | # |
625 | 628 | # Determine the final servlet name. |
@@ -776,11 +779,29 @@ def SendTransaction(self, serverName, request, response): |
776 | 779 | # |
777 | 780 | def PerformTransaction(self, request, response): |
778 | 781 |
|
| 782 | +# |
| 783 | +# If EMBEDDED_FIELDS_TOKEN is provided, send the request to the corresponding endpoint |
| 784 | +# |
| 785 | + fullUrl = request.Get(GatewayRequest.EMBEDDED_FIELDS_TOKEN) |
| 786 | + if fullUrl is not None: |
| 787 | + try: |
| 788 | + parsedUrl = urlsplit(fullUrl) |
| 789 | + request.Set(GatewayRequest.GATEWAY_SERVER, parsedUrl.hostname) |
| 790 | + request.Set(GatewayRequest.GATEWAY_SERVLET, |
| 791 | + parsedUrl.path + ("?" + parsedUrl.query if parsedUrl.query is not None else "")) |
| 792 | + if parsedUrl.port is not None: |
| 793 | + request.Set(GatewayRequest.GATEWAY_PORTNO, parsedUrl.port) |
| 794 | + except Exception as ex: |
| 795 | + response.Set(GatewayResponse.EXCEPTION, str(ex)) |
| 796 | + response.Set(GatewayResponse.RESPONSE_CODE, 4) |
| 797 | + response.Set(GatewayResponse.REASON_CODE, 401) |
| 798 | + return 4 # Validation error: Invalid URL |
| 799 | + |
779 | 800 | # |
780 | 801 | # If the request specifies a server name, use it. |
781 | 802 | # Otherwise, use the default. |
782 | 803 | # |
783 | | - serverName = request.Get("gatewayServer") |
| 804 | + serverName = request.Get(GatewayRequest.GATEWAY_SERVER) |
784 | 805 | if serverName != None: # Override? |
785 | 806 | serverList = [ serverName ] # Use this name |
786 | 807 | else: |
|
0 commit comments