Attempt to fix CI crash at Windows. (#465)
* Attempt to fix CI crash at Windows. Remove all cast[string] and cast[seq[byte]] from the codebase. * Address review comments.
This commit is contained in:
parent
0d55475c29
commit
9c93ab48de
|
@ -1125,14 +1125,18 @@ proc addTimer*(at: uint64, cb: CallbackFunc, udata: pointer = nil) {.
|
||||||
proc removeTimer*(at: Moment, cb: CallbackFunc, udata: pointer = nil) =
|
proc removeTimer*(at: Moment, cb: CallbackFunc, udata: pointer = nil) =
|
||||||
## Remove timer callback ``cb`` with absolute timestamp ``at`` from waiting
|
## Remove timer callback ``cb`` with absolute timestamp ``at`` from waiting
|
||||||
## queue.
|
## queue.
|
||||||
let loop = getThreadDispatcher()
|
let
|
||||||
var list = cast[seq[TimerCallback]](loop.timers)
|
loop = getThreadDispatcher()
|
||||||
var index = -1
|
index =
|
||||||
for i in 0..<len(list):
|
block:
|
||||||
if list[i].finishAt == at and list[i].function.function == cb and
|
var res = -1
|
||||||
list[i].function.udata == udata:
|
for i in 0 ..< len(loop.timers):
|
||||||
index = i
|
if (loop.timers[i].finishAt == at) and
|
||||||
|
(loop.timers[i].function.function == cb) and
|
||||||
|
(loop.timers[i].function.udata == udata):
|
||||||
|
res = i
|
||||||
break
|
break
|
||||||
|
res
|
||||||
if index != -1:
|
if index != -1:
|
||||||
loop.timers.del(index)
|
loop.timers.del(index)
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
# MIT license (LICENSE-MIT)
|
# MIT license (LICENSE-MIT)
|
||||||
import unittest2
|
import unittest2
|
||||||
import bearssl/[x509]
|
import bearssl/[x509]
|
||||||
|
import stew/byteutils
|
||||||
import ".."/chronos/unittest2/asynctests
|
import ".."/chronos/unittest2/asynctests
|
||||||
import ".."/chronos/streams/[tlsstream, chunkstream, boundstream]
|
import ".."/chronos/streams/[tlsstream, chunkstream, boundstream]
|
||||||
|
|
||||||
|
@ -102,11 +103,11 @@ suite "AsyncStream test suite":
|
||||||
var transp = await connect(server.localAddress())
|
var transp = await connect(server.localAddress())
|
||||||
var rstream = newAsyncStreamReader(transp)
|
var rstream = newAsyncStreamReader(transp)
|
||||||
await rstream.readExactly(addr buffer[0], 10)
|
await rstream.readExactly(addr buffer[0], 10)
|
||||||
check cast[string](buffer) == "0000000000"
|
check string.fromBytes(buffer) == "0000000000"
|
||||||
await rstream.readExactly(addr buffer[0], 10)
|
await rstream.readExactly(addr buffer[0], 10)
|
||||||
check cast[string](buffer) == "1111111111"
|
check string.fromBytes(buffer) == "1111111111"
|
||||||
await rstream.readExactly(addr buffer[0], 10)
|
await rstream.readExactly(addr buffer[0], 10)
|
||||||
check cast[string](buffer) == "2222222222"
|
check string.fromBytes(buffer) == "2222222222"
|
||||||
await rstream.closeWait()
|
await rstream.closeWait()
|
||||||
await transp.closeWait()
|
await transp.closeWait()
|
||||||
await server.join()
|
await server.join()
|
||||||
|
@ -135,15 +136,15 @@ suite "AsyncStream test suite":
|
||||||
var r1 = await rstream.readUntil(addr buffer[0], len(buffer), sep)
|
var r1 = await rstream.readUntil(addr buffer[0], len(buffer), sep)
|
||||||
check:
|
check:
|
||||||
r1 == 13
|
r1 == 13
|
||||||
cast[string](buffer) == "0000000000NNz"
|
string.fromBytes(buffer) == "0000000000NNz"
|
||||||
var r2 = await rstream.readUntil(addr buffer[0], len(buffer), sep)
|
var r2 = await rstream.readUntil(addr buffer[0], len(buffer), sep)
|
||||||
check:
|
check:
|
||||||
r2 == 13
|
r2 == 13
|
||||||
cast[string](buffer) == "1111111111NNz"
|
string.fromBytes(buffer) == "1111111111NNz"
|
||||||
var r3 = await rstream.readUntil(addr buffer[0], len(buffer), sep)
|
var r3 = await rstream.readUntil(addr buffer[0], len(buffer), sep)
|
||||||
check:
|
check:
|
||||||
r3 == 13
|
r3 == 13
|
||||||
cast[string](buffer) == "2222222222NNz"
|
string.fromBytes(buffer) == "2222222222NNz"
|
||||||
|
|
||||||
await rstream.closeWait()
|
await rstream.closeWait()
|
||||||
await transp.closeWait()
|
await transp.closeWait()
|
||||||
|
@ -198,9 +199,9 @@ suite "AsyncStream test suite":
|
||||||
var transp = await connect(server.localAddress())
|
var transp = await connect(server.localAddress())
|
||||||
var rstream = newAsyncStreamReader(transp)
|
var rstream = newAsyncStreamReader(transp)
|
||||||
var buf1 = await rstream.read(10)
|
var buf1 = await rstream.read(10)
|
||||||
check cast[string](buf1) == "0000000000"
|
check string.fromBytes(buf1) == "0000000000"
|
||||||
var buf2 = await rstream.read()
|
var buf2 = await rstream.read()
|
||||||
check cast[string](buf2) == "11111111112222222222"
|
check string.fromBytes(buf2) == "11111111112222222222"
|
||||||
await rstream.closeWait()
|
await rstream.closeWait()
|
||||||
await transp.closeWait()
|
await transp.closeWait()
|
||||||
await server.join()
|
await server.join()
|
||||||
|
@ -228,12 +229,12 @@ suite "AsyncStream test suite":
|
||||||
check:
|
check:
|
||||||
res1 == 10
|
res1 == 10
|
||||||
var buf1 = await rstream.read(10)
|
var buf1 = await rstream.read(10)
|
||||||
check cast[string](buf1) == "1111111111"
|
check string.fromBytes(buf1) == "1111111111"
|
||||||
var res2 = await rstream.consume(10)
|
var res2 = await rstream.consume(10)
|
||||||
check:
|
check:
|
||||||
res2 == 10
|
res2 == 10
|
||||||
var buf2 = await rstream.read(10)
|
var buf2 = await rstream.read(10)
|
||||||
check cast[string](buf2) == "3333333333"
|
check string.fromBytes(buf2) == "3333333333"
|
||||||
await rstream.closeWait()
|
await rstream.closeWait()
|
||||||
await transp.closeWait()
|
await transp.closeWait()
|
||||||
await server.join()
|
await server.join()
|
||||||
|
@ -255,7 +256,7 @@ suite "AsyncStream test suite":
|
||||||
await wstream2.write("00000")
|
await wstream2.write("00000")
|
||||||
await wstream2.write(addr s1[0], len(s1))
|
await wstream2.write(addr s1[0], len(s1))
|
||||||
await wstream2.write("11111")
|
await wstream2.write("11111")
|
||||||
await wstream2.write(cast[seq[byte]](s2))
|
await wstream2.write(s2.toBytes())
|
||||||
await wstream2.write("22222")
|
await wstream2.write("22222")
|
||||||
await wstream2.write(addr s3[0], len(s3))
|
await wstream2.write(addr s3[0], len(s3))
|
||||||
|
|
||||||
|
@ -275,11 +276,11 @@ suite "AsyncStream test suite":
|
||||||
var rstream = newAsyncStreamReader(transp)
|
var rstream = newAsyncStreamReader(transp)
|
||||||
var rstream2 = newChunkedStreamReader(rstream)
|
var rstream2 = newChunkedStreamReader(rstream)
|
||||||
await rstream2.readExactly(addr buffer[0], 10)
|
await rstream2.readExactly(addr buffer[0], 10)
|
||||||
check cast[string](buffer) == "0000000000"
|
check string.fromBytes(buffer) == "0000000000"
|
||||||
await rstream2.readExactly(addr buffer[0], 10)
|
await rstream2.readExactly(addr buffer[0], 10)
|
||||||
check cast[string](buffer) == "1111111111"
|
check string.fromBytes(buffer) == "1111111111"
|
||||||
await rstream2.readExactly(addr buffer[0], 10)
|
await rstream2.readExactly(addr buffer[0], 10)
|
||||||
check cast[string](buffer) == "2222222222"
|
check string.fromBytes(buffer) == "2222222222"
|
||||||
|
|
||||||
# We need to consume all the stream with finish markers, but there will
|
# We need to consume all the stream with finish markers, but there will
|
||||||
# be no actual data.
|
# be no actual data.
|
||||||
|
@ -309,7 +310,7 @@ suite "AsyncStream test suite":
|
||||||
await wstream2.write("11111")
|
await wstream2.write("11111")
|
||||||
await wstream2.write(s2)
|
await wstream2.write(s2)
|
||||||
await wstream2.write("22222")
|
await wstream2.write("22222")
|
||||||
await wstream2.write(cast[seq[byte]](s3))
|
await wstream2.write(s3.toBytes())
|
||||||
await wstream2.finish()
|
await wstream2.finish()
|
||||||
await wstream.finish()
|
await wstream.finish()
|
||||||
await wstream2.closeWait()
|
await wstream2.closeWait()
|
||||||
|
@ -330,15 +331,15 @@ suite "AsyncStream test suite":
|
||||||
var r1 = await rstream2.readUntil(addr buffer[0], len(buffer), sep)
|
var r1 = await rstream2.readUntil(addr buffer[0], len(buffer), sep)
|
||||||
check:
|
check:
|
||||||
r1 == 13
|
r1 == 13
|
||||||
cast[string](buffer) == "0000000000NNz"
|
string.fromBytes(buffer) == "0000000000NNz"
|
||||||
var r2 = await rstream2.readUntil(addr buffer[0], len(buffer), sep)
|
var r2 = await rstream2.readUntil(addr buffer[0], len(buffer), sep)
|
||||||
check:
|
check:
|
||||||
r2 == 13
|
r2 == 13
|
||||||
cast[string](buffer) == "1111111111NNz"
|
string.fromBytes(buffer) == "1111111111NNz"
|
||||||
var r3 = await rstream2.readUntil(addr buffer[0], len(buffer), sep)
|
var r3 = await rstream2.readUntil(addr buffer[0], len(buffer), sep)
|
||||||
check:
|
check:
|
||||||
r3 == 13
|
r3 == 13
|
||||||
cast[string](buffer) == "2222222222NNz"
|
string.fromBytes(buffer) == "2222222222NNz"
|
||||||
|
|
||||||
# We need to consume all the stream with finish markers, but there will
|
# We need to consume all the stream with finish markers, but there will
|
||||||
# be no actual data.
|
# be no actual data.
|
||||||
|
@ -411,7 +412,7 @@ suite "AsyncStream test suite":
|
||||||
var s3 = "2222222222"
|
var s3 = "2222222222"
|
||||||
await wstream2.write("0000000000")
|
await wstream2.write("0000000000")
|
||||||
await wstream2.write(s2)
|
await wstream2.write(s2)
|
||||||
await wstream2.write(cast[seq[byte]](s3))
|
await wstream2.write(s3.toBytes())
|
||||||
await wstream2.finish()
|
await wstream2.finish()
|
||||||
await wstream.finish()
|
await wstream.finish()
|
||||||
await wstream2.closeWait()
|
await wstream2.closeWait()
|
||||||
|
@ -427,9 +428,9 @@ suite "AsyncStream test suite":
|
||||||
var rstream = newAsyncStreamReader(transp)
|
var rstream = newAsyncStreamReader(transp)
|
||||||
var rstream2 = newChunkedStreamReader(rstream)
|
var rstream2 = newChunkedStreamReader(rstream)
|
||||||
var buf1 = await rstream2.read(10)
|
var buf1 = await rstream2.read(10)
|
||||||
check cast[string](buf1) == "0000000000"
|
check string.fromBytes(buf1) == "0000000000"
|
||||||
var buf2 = await rstream2.read()
|
var buf2 = await rstream2.read()
|
||||||
check cast[string](buf2) == "11111111112222222222"
|
check string.fromBytes(buf2) == "11111111112222222222"
|
||||||
|
|
||||||
# read() call will consume all the bytes and finish markers too, so
|
# read() call will consume all the bytes and finish markers too, so
|
||||||
# we just check stream for EOF.
|
# we just check stream for EOF.
|
||||||
|
@ -452,7 +453,7 @@ suite "AsyncStream test suite":
|
||||||
var wstream2 = newChunkedStreamWriter(wstream)
|
var wstream2 = newChunkedStreamWriter(wstream)
|
||||||
|
|
||||||
var s1 = "00000"
|
var s1 = "00000"
|
||||||
var s2 = cast[seq[byte]]("11111")
|
var s2 = "11111".toBytes()
|
||||||
var s3 = "22222"
|
var s3 = "22222"
|
||||||
|
|
||||||
await wstream2.write("00000")
|
await wstream2.write("00000")
|
||||||
|
@ -482,12 +483,12 @@ suite "AsyncStream test suite":
|
||||||
check:
|
check:
|
||||||
res1 == 10
|
res1 == 10
|
||||||
var buf1 = await rstream2.read(10)
|
var buf1 = await rstream2.read(10)
|
||||||
check cast[string](buf1) == "1111111111"
|
check string.fromBytes(buf1) == "1111111111"
|
||||||
var res2 = await rstream2.consume(10)
|
var res2 = await rstream2.consume(10)
|
||||||
check:
|
check:
|
||||||
res2 == 10
|
res2 == 10
|
||||||
var buf2 = await rstream2.read(10)
|
var buf2 = await rstream2.read(10)
|
||||||
check cast[string](buf2) == "3333333333"
|
check string.fromBytes(buf2) == "3333333333"
|
||||||
|
|
||||||
# We need to consume all the stream with finish markers, but there will
|
# We need to consume all the stream with finish markers, but there will
|
||||||
# be no actual data.
|
# be no actual data.
|
||||||
|
@ -596,7 +597,7 @@ suite "ChunkedStream test suite":
|
||||||
var rstream = newAsyncStreamReader(transp)
|
var rstream = newAsyncStreamReader(transp)
|
||||||
var rstream2 = newChunkedStreamReader(rstream)
|
var rstream2 = newChunkedStreamReader(rstream)
|
||||||
var res = await rstream2.read()
|
var res = await rstream2.read()
|
||||||
var ress = cast[string](res)
|
var ress = string.fromBytes(res)
|
||||||
await rstream2.closeWait()
|
await rstream2.closeWait()
|
||||||
await rstream.closeWait()
|
await rstream.closeWait()
|
||||||
await transp.closeWait()
|
await transp.closeWait()
|
||||||
|
@ -917,7 +918,7 @@ suite "TLSStream test suite":
|
||||||
await cwriter.closeWait()
|
await cwriter.closeWait()
|
||||||
await conn.closeWait()
|
await conn.closeWait()
|
||||||
await server.join()
|
await server.join()
|
||||||
return cast[string](res) == (testMessage & "\r\n")
|
return string.fromBytes(res) == (testMessage & "\r\n")
|
||||||
|
|
||||||
test "Simple server with RSA self-signed certificate":
|
test "Simple server with RSA self-signed certificate":
|
||||||
let res = waitFor(checkSSLServer(SelfSignedRsaKey, SelfSignedRsaCert))
|
let res = waitFor(checkSSLServer(SelfSignedRsaKey, SelfSignedRsaCert))
|
||||||
|
@ -961,7 +962,7 @@ suite "TLSStream test suite":
|
||||||
await cwriter.closeWait()
|
await cwriter.closeWait()
|
||||||
await conn.closeWait()
|
await conn.closeWait()
|
||||||
await server.join()
|
await server.join()
|
||||||
return cast[string](res)
|
return string.fromBytes(res)
|
||||||
let res = waitFor checkTrustAnchors("Some message")
|
let res = waitFor checkTrustAnchors("Some message")
|
||||||
check res == "Some message\r\n"
|
check res == "Some message\r\n"
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
# Apache License, version 2.0, (LICENSE-APACHEv2)
|
# Apache License, version 2.0, (LICENSE-APACHEv2)
|
||||||
# MIT license (LICENSE-MIT)
|
# MIT license (LICENSE-MIT)
|
||||||
import std/[strutils, net]
|
import std/[strutils, net]
|
||||||
|
import stew/byteutils
|
||||||
import ".."/chronos/unittest2/asynctests
|
import ".."/chronos/unittest2/asynctests
|
||||||
import ".."/chronos
|
import ".."/chronos
|
||||||
|
|
||||||
|
@ -474,7 +475,7 @@ suite "Datagram Transport test suite":
|
||||||
proc clientMark(transp: DatagramTransport,
|
proc clientMark(transp: DatagramTransport,
|
||||||
raddr: TransportAddress): Future[void] {.async.} =
|
raddr: TransportAddress): Future[void] {.async.} =
|
||||||
var bmsg = transp.getMessage()
|
var bmsg = transp.getMessage()
|
||||||
var smsg = cast[string](bmsg)
|
var smsg = string.fromBytes(bmsg)
|
||||||
if smsg == expectMessage:
|
if smsg == expectMessage:
|
||||||
inc(res)
|
inc(res)
|
||||||
transp.close()
|
transp.close()
|
||||||
|
@ -486,7 +487,7 @@ suite "Datagram Transport test suite":
|
||||||
|
|
||||||
proc testAnyAddress(): Future[int] {.async.} =
|
proc testAnyAddress(): Future[int] {.async.} =
|
||||||
var expectStr = "ANYADDRESS MESSAGE"
|
var expectStr = "ANYADDRESS MESSAGE"
|
||||||
var expectSeq = cast[seq[byte]](expectStr)
|
var expectSeq = expectStr.toBytes()
|
||||||
let ta = initTAddress("0.0.0.0:0")
|
let ta = initTAddress("0.0.0.0:0")
|
||||||
var res = 0
|
var res = 0
|
||||||
var event = newAsyncEvent()
|
var event = newAsyncEvent()
|
||||||
|
@ -494,7 +495,7 @@ suite "Datagram Transport test suite":
|
||||||
proc clientMark1(transp: DatagramTransport,
|
proc clientMark1(transp: DatagramTransport,
|
||||||
raddr: TransportAddress): Future[void] {.async.} =
|
raddr: TransportAddress): Future[void] {.async.} =
|
||||||
var bmsg = transp.getMessage()
|
var bmsg = transp.getMessage()
|
||||||
var smsg = cast[string](bmsg)
|
var smsg = string.fromBytes(bmsg)
|
||||||
if smsg == expectStr:
|
if smsg == expectStr:
|
||||||
inc(res)
|
inc(res)
|
||||||
event.fire()
|
event.fire()
|
||||||
|
@ -545,7 +546,7 @@ suite "Datagram Transport test suite":
|
||||||
proc process1(transp: DatagramTransport,
|
proc process1(transp: DatagramTransport,
|
||||||
raddr: TransportAddress): Future[void] {.async.} =
|
raddr: TransportAddress): Future[void] {.async.} =
|
||||||
var bmsg = transp.getMessage()
|
var bmsg = transp.getMessage()
|
||||||
var smsg = cast[string](bmsg)
|
var smsg = string.fromBytes(bmsg)
|
||||||
if smsg == expectStr:
|
if smsg == expectStr:
|
||||||
inc(res)
|
inc(res)
|
||||||
event.fire()
|
event.fire()
|
||||||
|
|
|
@ -9,7 +9,7 @@ import std/[strutils, sha1]
|
||||||
import ".."/chronos/unittest2/asynctests
|
import ".."/chronos/unittest2/asynctests
|
||||||
import ".."/chronos,
|
import ".."/chronos,
|
||||||
".."/chronos/apps/http/[httpserver, shttpserver, httpclient]
|
".."/chronos/apps/http/[httpserver, shttpserver, httpclient]
|
||||||
import stew/base10
|
import stew/[byteutils, base10]
|
||||||
|
|
||||||
{.used.}
|
{.used.}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ suite "HTTP client testing suite":
|
||||||
var req = HttpClientRequestRef.new(session, ha, item[0])
|
var req = HttpClientRequestRef.new(session, ha, item[0])
|
||||||
let response = await fetch(req)
|
let response = await fetch(req)
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
let data = cast[string](response.data)
|
let data = string.fromBytes(response.data)
|
||||||
if data == item[1]:
|
if data == item[1]:
|
||||||
inc(counter)
|
inc(counter)
|
||||||
await req.closeWait()
|
await req.closeWait()
|
||||||
|
@ -173,7 +173,7 @@ suite "HTTP client testing suite":
|
||||||
var req = HttpClientRequestRef.new(session, ha, item[0])
|
var req = HttpClientRequestRef.new(session, ha, item[0])
|
||||||
let response = await fetch(req)
|
let response = await fetch(req)
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
let data = cast[string](response.data)
|
let data = string.fromBytes(response.data)
|
||||||
if data == item[1]:
|
if data == item[1]:
|
||||||
inc(counter)
|
inc(counter)
|
||||||
await req.closeWait()
|
await req.closeWait()
|
||||||
|
@ -318,7 +318,7 @@ suite "HTTP client testing suite":
|
||||||
of "/test/big_request":
|
of "/test/big_request":
|
||||||
if request.hasBody():
|
if request.hasBody():
|
||||||
let body = await request.getBody()
|
let body = await request.getBody()
|
||||||
let digest = $secureHash(cast[string](body))
|
let digest = $secureHash(string.fromBytes(body))
|
||||||
return await request.respond(Http200, digest)
|
return await request.respond(Http200, digest)
|
||||||
else:
|
else:
|
||||||
return await request.respond(Http400, "Missing content body")
|
return await request.respond(Http400, "Missing content body")
|
||||||
|
@ -348,7 +348,7 @@ suite "HTTP client testing suite":
|
||||||
session, ha, item[0], headers = headers
|
session, ha, item[0], headers = headers
|
||||||
)
|
)
|
||||||
|
|
||||||
var expectDigest = $secureHash(cast[string](data))
|
var expectDigest = $secureHash(string.fromBytes(data))
|
||||||
# Sending big request by 1024bytes long chunks
|
# Sending big request by 1024bytes long chunks
|
||||||
var writer = await open(request)
|
var writer = await open(request)
|
||||||
var offset = 0
|
var offset = 0
|
||||||
|
@ -364,7 +364,7 @@ suite "HTTP client testing suite":
|
||||||
|
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
var res = await response.getBodyBytes()
|
var res = await response.getBodyBytes()
|
||||||
if cast[string](res) == expectDigest:
|
if string.fromBytes(res) == expectDigest:
|
||||||
inc(counter)
|
inc(counter)
|
||||||
await response.closeWait()
|
await response.closeWait()
|
||||||
await request.closeWait()
|
await request.closeWait()
|
||||||
|
@ -388,7 +388,7 @@ suite "HTTP client testing suite":
|
||||||
of "/test/big_chunk_request":
|
of "/test/big_chunk_request":
|
||||||
if request.hasBody():
|
if request.hasBody():
|
||||||
let body = await request.getBody()
|
let body = await request.getBody()
|
||||||
let digest = $secureHash(cast[string](body))
|
let digest = $secureHash(string.fromBytes(body))
|
||||||
return await request.respond(Http200, digest)
|
return await request.respond(Http200, digest)
|
||||||
else:
|
else:
|
||||||
return await request.respond(Http400, "Missing content body")
|
return await request.respond(Http400, "Missing content body")
|
||||||
|
@ -418,7 +418,7 @@ suite "HTTP client testing suite":
|
||||||
session, ha, item[0], headers = headers
|
session, ha, item[0], headers = headers
|
||||||
)
|
)
|
||||||
|
|
||||||
var expectDigest = $secureHash(cast[string](data))
|
var expectDigest = $secureHash(string.fromBytes(data))
|
||||||
# Sending big request by 1024bytes long chunks
|
# Sending big request by 1024bytes long chunks
|
||||||
var writer = await open(request)
|
var writer = await open(request)
|
||||||
var offset = 0
|
var offset = 0
|
||||||
|
@ -434,7 +434,7 @@ suite "HTTP client testing suite":
|
||||||
|
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
var res = await response.getBodyBytes()
|
var res = await response.getBodyBytes()
|
||||||
if cast[string](res) == expectDigest:
|
if string.fromBytes(res) == expectDigest:
|
||||||
inc(counter)
|
inc(counter)
|
||||||
await response.closeWait()
|
await response.closeWait()
|
||||||
await request.closeWait()
|
await request.closeWait()
|
||||||
|
@ -491,12 +491,12 @@ suite "HTTP client testing suite":
|
||||||
]
|
]
|
||||||
var request = HttpClientRequestRef.new(
|
var request = HttpClientRequestRef.new(
|
||||||
session, ha, MethodPost, headers = headers,
|
session, ha, MethodPost, headers = headers,
|
||||||
body = cast[seq[byte]](PostRequests[0][1]))
|
body = PostRequests[0][1].toBytes())
|
||||||
var response = await send(request)
|
var response = await send(request)
|
||||||
|
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
var res = await response.getBodyBytes()
|
var res = await response.getBodyBytes()
|
||||||
if cast[string](res) == PostRequests[0][2]:
|
if string.fromBytes(res) == PostRequests[0][2]:
|
||||||
inc(counter)
|
inc(counter)
|
||||||
await response.closeWait()
|
await response.closeWait()
|
||||||
await request.closeWait()
|
await request.closeWait()
|
||||||
|
@ -532,7 +532,7 @@ suite "HTTP client testing suite":
|
||||||
var response = await request.finish()
|
var response = await request.finish()
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
var res = await response.getBodyBytes()
|
var res = await response.getBodyBytes()
|
||||||
if cast[string](res) == PostRequests[1][2]:
|
if string.fromBytes(res) == PostRequests[1][2]:
|
||||||
inc(counter)
|
inc(counter)
|
||||||
await response.closeWait()
|
await response.closeWait()
|
||||||
await request.closeWait()
|
await request.closeWait()
|
||||||
|
@ -601,7 +601,7 @@ suite "HTTP client testing suite":
|
||||||
var response = await send(request)
|
var response = await send(request)
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
var res = await response.getBodyBytes()
|
var res = await response.getBodyBytes()
|
||||||
if cast[string](res) == PostRequests[0][3]:
|
if string.fromBytes(res) == PostRequests[0][3]:
|
||||||
inc(counter)
|
inc(counter)
|
||||||
await response.closeWait()
|
await response.closeWait()
|
||||||
await request.closeWait()
|
await request.closeWait()
|
||||||
|
@ -634,7 +634,7 @@ suite "HTTP client testing suite":
|
||||||
let response = await request.finish()
|
let response = await request.finish()
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
var res = await response.getBodyBytes()
|
var res = await response.getBodyBytes()
|
||||||
if cast[string](res) == PostRequests[1][3]:
|
if string.fromBytes(res) == PostRequests[1][3]:
|
||||||
inc(counter)
|
inc(counter)
|
||||||
await response.closeWait()
|
await response.closeWait()
|
||||||
await request.closeWait()
|
await request.closeWait()
|
||||||
|
|
Loading…
Reference in New Issue