From 95a34f7efe7f27ec437831f6ee97d1cef26f5636 Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Tue, 27 Oct 2015 00:21:46 +0100 Subject: [PATCH] Start HTTP helper class for OSC. --- http.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 http.py diff --git a/http.py b/http.py new file mode 100644 index 0000000..db18826 --- /dev/null +++ b/http.py @@ -0,0 +1,25 @@ +""" +HTTP helper class +@author Markus Birth + +RFC: http://www.w3.org/Protocols/rfc2616/rfc2616.html +Inspiration: http://www.wellho.net/resources/ex.php4?item=y303/browser.py +""" +import re +import socket + +class HTTP: + def parse_url(self, url): + # Taken from: https://tools.ietf.org/html/rfc3986#appendix-B + re = re.match('^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?', url) + scheme = re.group(2) + hostpart = re.group(4) # user:pass@host:port + uri = re.group(5) + query = re.group(7) + fragment = re.group(9) + + + + def do_request(self, url, payload=False, type="GET"): + # explode url into: protocol, host, port, uri (maybe GET parameters), hash + pass