I have an elastic load balancer running on aws cloud. I have attached a HTTPS listener to it on port 443, and it is using a certificate in certificate manager. I want to send https requests from a python script to the elastic load. I can't figure out the exact api call that I should make to implement this.
You can make https get request to the DNS of the ELB.
To generate HTTPS request use following script quoted from this answer .
import urllib.request r = urllib.request.urlopen('<DNS OF ELB>') print(r.read())
If you really want to use http.client, you must call
endheaders
after you send the request headers:import http.client conn = http.client.HTTPSConnection('DNS OF ELB', 443) conn.putrequest('GET', '/') conn.endheaders() # <--- r = conn.getresponse() print(r.read())
As a shortcut to
putrequest
/endheaders
, you can also use therequest
method, like this:import http.client conn = http.client.HTTPSConnection('DOMAIN', 443) conn.request('GET', '/') # <--- r = conn.getresponse() print(r.read())
Update 1
For Python 2.7 You can use httplib or urllib2
If you are using httplib
, HTTPS supports only if the socket
module was compiled with SSL support.
For urllib2 refer this article .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.