INNER CODE UNIT · Python
send_http_request
nordnet/next-api-v2-examples · python3/test_program.py:116
def send_http_request(conn, method, uri, params, headers):
"""
Send a HTTP request
"""
conn.request(method, uri, params, headers)
r = conn.getresponse()
print("<< HTTP request " + method + " " + uri)
response = r.read().decode('utf-8')
j = json.loads(response)
print(json.dumps(j, indent=4, sort_keys=True))
return j
def connect_to_feed(public_feed_hostname, public_feed_port):
"""
Connect to the feed and get back a TCP socket
"""
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if public_feed_port == 443: