File tree 1 file changed +16
-12
lines changed 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change 1
1
discard """
2
- cmd: "nim c -r -d:ssl $file"
3
- exitcode: 0
2
+ matrix: "-d:ssl"
4
3
"""
5
4
6
5
import std/ net
6
+ from std/ strutils import `%`
7
7
8
- # Issue 15215 - https://github.com/nim-lang/Nim/issues/ 15215
8
+ # bug # 15215
9
9
proc test () =
10
- var
11
- ctx = newContext ()
12
- socket = newSocket ()
10
+ let ctx = newContext ()
13
11
14
- wrapSocket (ctx, socket)
12
+ proc fn (url: string ) =
13
+ let socket = newSocket ()
14
+ defer : close (socket)
15
+ connect (socket, url, Port (443 ), 5000 ) # typically 20 could be enough
16
+ send (socket, " GET / HTTP/1.0\n Host: $#\n Connection: close\n\n " % [url])
17
+ wrapSocket (ctx, socket)
15
18
16
- connect (socket, " www.nim-lang.org" , Port (443 ), 5000 )
17
-
18
- send (socket, " GET / HTTP/1.0\n Host: www.nim-lang.org\n Connection: close\n\n " )
19
-
20
- close (socket)
19
+ # trying 2 sites makes it more resilent: refs #17458 this could give:
20
+ # Error: unhandled exception: Call to 'connect' timed out. [TimeoutError]
21
+ try :
22
+ fn (" www.nim-lang.org" )
23
+ except TimeoutError :
24
+ fn (" www.google.com" )
21
25
22
26
test ()
You can’t perform that action at this time.
0 commit comments