Fixed some warnings in httpclient, net, and openssl.

This commit is contained in:
Dominik Picheta 2016-04-04 21:28:21 +01:00
commit 8050f43588
3 changed files with 6 additions and 8 deletions

View file

@ -428,9 +428,6 @@ proc recvLine*(socket: AsyncSocket,
## ##
## **Warning**: ``recvLine`` on unbuffered sockets assumes that the protocol ## **Warning**: ``recvLine`` on unbuffered sockets assumes that the protocol
## uses ``\r\L`` to delimit a new line. ## uses ``\r\L`` to delimit a new line.
template addNLIfEmpty(): stmt =
if result.len == 0:
result.add("\c\L")
assert SocketFlag.Peek notin flags ## TODO: assert SocketFlag.Peek notin flags ## TODO:
# TODO: Optimise this # TODO: Optimise this
@ -458,7 +455,8 @@ proc bindAddr*(socket: AsyncSocket, port = Port(0), address = "") {.
of AF_INET6: realaddr = "::" of AF_INET6: realaddr = "::"
of AF_INET: realaddr = "0.0.0.0" of AF_INET: realaddr = "0.0.0.0"
else: else:
raiseOSError("Unknown socket address family and no address specified to bindAddr") raise newException(ValueError,
"Unknown socket address family and no address specified to bindAddr")
var aiList = getAddrInfo(realaddr, port, socket.domain) var aiList = getAddrInfo(realaddr, port, socket.domain)
if bindAddr(socket.fd, aiList.ai_addr, aiList.ai_addrlen.Socklen) < 0'i32: if bindAddr(socket.fd, aiList.ai_addr, aiList.ai_addrlen.Socklen) < 0'i32:

View file

@ -335,7 +335,7 @@ proc addFiles*(p: var MultipartData, xs: openarray[tuple[name, file: string]]):
var m = newMimetypes() var m = newMimetypes()
for name, file in xs.items: for name, file in xs.items:
var contentType: string var contentType: string
let (dir, fName, ext) = splitFile(file) let (_, fName, ext) = splitFile(file)
if ext.len > 0: if ext.len > 0:
contentType = m.getMimetype(ext[1..ext.high], nil) contentType = m.getMimetype(ext[1..ext.high], nil)
p.add(name, readFile(file), fName & ext, contentType) p.add(name, readFile(file), fName & ext, contentType)
@ -627,7 +627,7 @@ proc newAsyncHttpClient*(userAgent = defUserAgent,
result.userAgent = defUserAgent result.userAgent = defUserAgent
result.maxRedirects = maxRedirects result.maxRedirects = maxRedirects
when defined(ssl): when defined(ssl):
result.sslContext = net.SslContext(sslContext) result.sslContext = sslContext
proc close*(client: AsyncHttpClient) = proc close*(client: AsyncHttpClient) =
## Closes any connections held by the HTTP client. ## Closes any connections held by the HTTP client.

View file

@ -260,7 +260,7 @@ proc OpenSSL_add_all_algorithms*(){.cdecl, dynlib: DLLUtilName, importc: "OPENSS
proc OPENSSL_config*(configName: cstring){.cdecl, dynlib: DLLSSLName, importc.} proc OPENSSL_config*(configName: cstring){.cdecl, dynlib: DLLSSLName, importc.}
when not useWinVersion: when not useWinVersion and not defined(macosx):
proc CRYPTO_set_mem_functions(a,b,c: pointer){.cdecl, proc CRYPTO_set_mem_functions(a,b,c: pointer){.cdecl,
dynlib: DLLUtilName, importc.} dynlib: DLLUtilName, importc.}
@ -532,7 +532,7 @@ proc md5_File* (file: string): string {.raises: [IOError,Exception].} =
result = hexStr(buf) result = hexStr(buf)
proc md5_Str* (str:string): string {.raises:[IOError].} = proc md5_Str*(str:string): string =
##Generate MD5 hash for a string. Result is a 32 character ##Generate MD5 hash for a string. Result is a 32 character
#hex string with lowercase characters #hex string with lowercase characters
var var