added when() block so that the compiler doesn't try to link SSL methods when SSL isn't available
This commit is contained in:
parent
0a03b18ae9
commit
0ada2aedfa
1 changed files with 24 additions and 21 deletions
|
|
@ -418,6 +418,7 @@ proc request*(url: string, httpMethod: string, extraHeaders = "",
|
||||||
# send the appropiate CONNECT header. If not, simply connect to the proper
|
# send the appropiate CONNECT header. If not, simply connect to the proper
|
||||||
# host (which may still be the proxy, for normal HTTP)
|
# host (which may still be the proxy, for normal HTTP)
|
||||||
if proxy != nil and hostUrl.scheme == "https":
|
if proxy != nil and hostUrl.scheme == "https":
|
||||||
|
when defined(ssl):
|
||||||
var connectHeaders = "CONNECT "
|
var connectHeaders = "CONNECT "
|
||||||
let targetPort = if hostUrl.port == "": 443 else: hostUrl.port.parseInt
|
let targetPort = if hostUrl.port == "": 443 else: hostUrl.port.parseInt
|
||||||
connectHeaders.add(hostUrl.hostname)
|
connectHeaders.add(hostUrl.hostname)
|
||||||
|
|
@ -440,6 +441,8 @@ proc request*(url: string, httpMethod: string, extraHeaders = "",
|
||||||
"The proxy server rejected a CONNECT request, " &
|
"The proxy server rejected a CONNECT request, " &
|
||||||
"so a secure connection could not be established.")
|
"so a secure connection could not be established.")
|
||||||
sslContext.wrapConnectedSocket(s, handshakeAsClient)
|
sslContext.wrapConnectedSocket(s, handshakeAsClient)
|
||||||
|
else:
|
||||||
|
raise newException(HttpRequestError, "SSL support not available. Cannot connect via proxy over SSL")
|
||||||
else:
|
else:
|
||||||
if timeout == -1:
|
if timeout == -1:
|
||||||
s.connect(r.hostname, port)
|
s.connect(r.hostname, port)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue