-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_http.py
35 lines (29 loc) · 875 Bytes
/
test_http.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
import sys
sys.path.append("src/");
from config_manager import ConfigManager
############################
## HTTP POSTS
############################
import httplib
from xml.dom import minidom
def getText(nodelist):
rc = []
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc.append(node.data)
return ''.join(rc)
http_host = ConfigManager.get("app", "callback_host");
http_site = ConfigManager.get("app", "callback_site");
connection = httplib.HTTPConnection(http_host)
connection.request("GET", "/" + http_site)
response = connection.getresponse()
if response.status == 200:
data = response.read()
dom = minidom.parseString(data)
elements = dom.getElementsByTagName("href")
if len(elements) > 0:
print getText(elements[0].childNodes)
else:
print "ErrorCode: %d", response.status
connection.close()