mirror of
https://github.com/Leseratte10/acsm-calibre-plugin
synced 2024-12-27 09:58:19 +01:00
Use HTTP if no protocol is included in URL (fixes #22)
This commit is contained in:
parent
b2b88abd06
commit
137fc82fa8
1 changed files with 8 additions and 0 deletions
|
@ -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 a new issue