parent
f3a6427109
commit
1d19cd660f
1 changed files with 16 additions and 12 deletions
|
|
@ -1,22 +1,26 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nim c -r -d:ssl $file"
|
matrix: "-d:ssl"
|
||||||
exitcode: 0
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import std/net
|
import std/net
|
||||||
|
from std/strutils import `%`
|
||||||
|
|
||||||
# Issue 15215 - https://github.com/nim-lang/Nim/issues/15215
|
# bug #15215
|
||||||
proc test() =
|
proc test() =
|
||||||
var
|
let ctx = newContext()
|
||||||
ctx = newContext()
|
|
||||||
socket = newSocket()
|
|
||||||
|
|
||||||
wrapSocket(ctx, socket)
|
proc fn(url: string) =
|
||||||
|
let socket = newSocket()
|
||||||
|
defer: close(socket)
|
||||||
|
connect(socket, url, Port(443), 5000) # typically 20 could be enough
|
||||||
|
send(socket, "GET / HTTP/1.0\nHost: $#\nConnection: close\n\n" % [url])
|
||||||
|
wrapSocket(ctx, socket)
|
||||||
|
|
||||||
connect(socket, "www.nim-lang.org", Port(443), 5000)
|
# trying 2 sites makes it more resilent: refs #17458 this could give:
|
||||||
|
# Error: unhandled exception: Call to 'connect' timed out. [TimeoutError]
|
||||||
send(socket, "GET / HTTP/1.0\nHost: www.nim-lang.org\nConnection: close\n\n")
|
try:
|
||||||
|
fn("www.nim-lang.org")
|
||||||
close(socket)
|
except TimeoutError:
|
||||||
|
fn("www.google.com")
|
||||||
|
|
||||||
test()
|
test()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue