Start HTTP helper class for OSC.

This commit is contained in:
Markus Birth 2015-10-27 00:21:46 +01:00
parent bbb7f72840
commit 95a34f7efe

25
http.py Normal file
View File

@ -0,0 +1,25 @@
"""
HTTP helper class
@author Markus Birth <markus@birth-online.de>
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