Skip to content

Commit fb3e460

Browse files
authored
Improve SSL error message in httpclient.
1 parent 6f0bb6e commit fb3e460

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/pure/httpclient.nim

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ proc request*(url: string, httpMethod: string, extraHeaders = "",
507507
port = net.Port(443)
508508
else:
509509
raise newException(HttpRequestError,
510-
"SSL support is not available. Cannot connect over SSL.")
510+
"SSL support is not available. Cannot connect over SSL. Compile with -d:ssl to enable.")
511511
if r.port != "":
512512
port = net.Port(r.port.parseInt)
513513

@@ -540,7 +540,8 @@ proc request*(url: string, httpMethod: string, extraHeaders = "",
540540
"so a secure connection could not be established.")
541541
sslContext.wrapConnectedSocket(s, handshakeAsClient, hostUrl.hostname)
542542
else:
543-
raise newException(HttpRequestError, "SSL support not available. Cannot connect via proxy over SSL")
543+
raise newException(HttpRequestError, "SSL support not available. Cannot " &
544+
"connect via proxy over SSL. Compile with -d:ssl to enable.")
544545
else:
545546
if timeout == -1:
546547
s.connect(r.hostname, port)
@@ -1087,7 +1088,7 @@ proc newConnection(client: HttpClient | AsyncHttpClient,
10871088

10881089
if isSsl and not defined(ssl):
10891090
raise newException(HttpRequestError,
1090-
"SSL support is not available. Cannot connect over SSL.")
1091+
"SSL support is not available. Cannot connect over SSL. Compile with -d:ssl to enable.")
10911092

10921093
if client.connected:
10931094
client.close()
@@ -1137,7 +1138,7 @@ proc newConnection(client: HttpClient | AsyncHttpClient,
11371138
client.socket, handshakeAsClient, url.hostname)
11381139
else:
11391140
raise newException(HttpRequestError,
1140-
"SSL support is not available. Cannot connect over SSL.")
1141+
"SSL support is not available. Cannot connect over SSL. Compile with -d:ssl to enable.")
11411142

11421143
# May be connected through proxy but remember actual URL being accessed
11431144
client.currentURL = url
@@ -1333,4 +1334,4 @@ proc downloadFile*(client: AsyncHttpClient, url: string,
13331334
finally:
13341335
result.addCallback(
13351336
proc () = client.getBody = true
1336-
)
1337+
)

0 commit comments

Comments
 (0)