SHARE
TWEET

Untitled

alexver Oct 23rd, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import BaseHTTPServer, SimpleHTTPServer
  2. import SocketServer
  3. import argparse
  4. import thread
  5. import os.path
  6. import ssl
  7. import xml.etree.ElementTree as ET
  8.  
  9. class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
  10.     actionId = "null"
  11.     windowSessionId = "null"
  12.  
  13.     def _set_headers(self):
  14.         self.send_response(200)
  15.         self.send_header('Content-type', 'application/xml')
  16.         self.end_headers()
  17.  
  18.     def do_GET(self):
  19.         self._set_headers()
  20.         self.wfile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
  21.            "<response>"
  22.                 "<actionId>" + self.actionId + "</actionId>"
  23.                 "<windowSessionId>" + self. windowSessionId + "</windowSessionId>"
  24.             "</response>")
  25.  
  26.     def do_POST(self):
  27.         self._set_headers()
  28.         request_headers = self.headers
  29.         content_length = request_headers.getheaders('content-length')
  30.         length = int(content_length[0]) if content_length else 0
  31.         print(request_headers)
  32.         xml = self.rfile.read(length)
  33.         print(xml)
  34.         root = ET.fromstring(xml)
  35.         messageId = root.find("{http://www.playtech.com/services/login}messageId").text
  36.         flowId = root.find("{playtech.com/galaxy/core}flow").get('id')
  37.         actionID = root.find("{http://www.playtech.com/services/login}actionId").text
  38.         self.actionId = actionID
  39.         print("MessageId: " + messageId)
  40.         print("FlowId: " + flowId)
  41.         print("ActionId: " + actionID)
  42.         self.wfile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns34:notifyActionOpenResponse xmlns:ns34=\"http://www.playtech.com/services/login\" xmlns:ns4=\"playtech.com/galaxy/core\" xmlns:ns31=\"http://www.playtech.com/services/common\"><ns4:flow id=\"" + flowId + "\"/><ns34:messageId>" + messageId + "</ns34:messageId><ns34:errorCode>0</ns34:errorCode></ns34:notifyActionOpenResponse>")
  43.  
  44.  
  45.  
  46. def http_server(port, handler):
  47.     httpd = SocketServer.TCPServer(("", port), handler)
  48.     httpd.serve_forever()
  49.  
  50. # Parse command-line arguments
  51. parser = argparse.ArgumentParser(description='Simple HTTP web server with HTTPS support which logs all incoming requests and collects some stats.')
  52. parser.add_argument('--http_port', type=int, dest='http_port', default=8000, help='Application HTTP port number')
  53. args = parser.parse_args()
  54.  
  55. if __name__=='__main__':
  56.     http_server(args.http_port, Handler)
  57.     # thread.start_new_thread(https_server, (args.https_port, Handler, args.cert))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top