mirror of
https://github.com/Leseratte10/acsm-calibre-plugin.git
synced 2024-12-23 01:34:36 +06:00
Use HTTP if no protocol is included in URL (fixes #22)
This commit is contained in:
parent
b2b88abd06
commit
137fc82fa8
@ -319,6 +319,14 @@ def sendPOSTHTTPRequest(URL, document, type, returnRC = False):
|
|||||||
ctx.check_hostname = False
|
ctx.check_hostname = False
|
||||||
ctx.verify_mode = ssl.CERT_NONE
|
ctx.verify_mode = ssl.CERT_NONE
|
||||||
|
|
||||||
|
# Make sure URL has a protocol
|
||||||
|
# Some vendors (see issue #22) apparently don't include "http://" in some of their URLs.
|
||||||
|
# Python returns an error when it encounters such a URL, so just add that prefix if it's not present.
|
||||||
|
|
||||||
|
if not "://" in URL:
|
||||||
|
print("Provider is using malformed URL %s, fixing." % (URL))
|
||||||
|
URL = "http://" + URL
|
||||||
|
|
||||||
req = ulib.Request(url=URL, headers=headers, data=document)
|
req = ulib.Request(url=URL, headers=headers, data=document)
|
||||||
try:
|
try:
|
||||||
handler = ulib.urlopen(req, context=ctx)
|
handler = ulib.urlopen(req, context=ctx)
|
||||||
|
Loading…
Reference in New Issue
Block a user