mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
* thttpclient.nim: respect NIM_TESTAMENT_REMOTE_NETWORKING * tnetconnect.nim: respect NIM_TESTAMENT_REMOTE_NETWORKING
31 lines
748 B
Nim
31 lines
748 B
Nim
discard """
|
|
disabled: "i386"
|
|
matrix: "-d:ssl"
|
|
"""
|
|
|
|
import std/net
|
|
from std/strutils import `%`
|
|
from stdtest/testutils import enableRemoteNetworking
|
|
|
|
# bug #15215
|
|
proc test() =
|
|
let ctx = newContext()
|
|
|
|
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)
|
|
|
|
# trying 2 sites makes it more resilent: refs #17458 this could give:
|
|
# * Call to 'connect' timed out. [TimeoutError]
|
|
# * No route to host [OSError]
|
|
try:
|
|
fn("www.nim-lang.org")
|
|
except TimeoutError, OSError:
|
|
fn("www.google.com")
|
|
|
|
when enableRemoteNetworking:
|
|
test()
|