Fixed recvLine deprecation warnings.
This commit is contained in:
parent
43499b9f07
commit
e3d097c4e9
6 changed files with 72 additions and 80 deletions
|
|
@ -126,7 +126,7 @@ type
|
||||||
|
|
||||||
handleTask*: proc (s: PAsyncSocket) {.closure.}
|
handleTask*: proc (s: PAsyncSocket) {.closure.}
|
||||||
|
|
||||||
lineBuffer: TaintedString ## Temporary storage for ``recvLine``
|
lineBuffer: TaintedString ## Temporary storage for ``readLine``
|
||||||
sendBuffer: string ## Temporary storage for ``send``
|
sendBuffer: string ## Temporary storage for ``send``
|
||||||
sslNeedAccept: bool
|
sslNeedAccept: bool
|
||||||
proto: TProtocol
|
proto: TProtocol
|
||||||
|
|
@ -635,7 +635,7 @@ when isMainModule:
|
||||||
proc testRead(s: PAsyncSocket, no: int) =
|
proc testRead(s: PAsyncSocket, no: int) =
|
||||||
echo("Reading! " & $no)
|
echo("Reading! " & $no)
|
||||||
var data = ""
|
var data = ""
|
||||||
if not s.recvLine(data):
|
if not s.readLine(data):
|
||||||
OSError()
|
OSError()
|
||||||
if data == "":
|
if data == "":
|
||||||
echo("Closing connection. " & $no)
|
echo("Closing connection. " & $no)
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ template blockingOperation(sock: TSocket, body: stmt) {.immediate.} =
|
||||||
proc expectReply(ftp: PFTPClient): TaintedString =
|
proc expectReply(ftp: PFTPClient): TaintedString =
|
||||||
result = TaintedString""
|
result = TaintedString""
|
||||||
blockingOperation(ftp.getCSock()):
|
blockingOperation(ftp.getCSock()):
|
||||||
if not ftp.getCSock().recvLine(result): setLen(result.string, 0)
|
ftp.getCSock().readLine(result)
|
||||||
|
|
||||||
proc send*(ftp: PFTPClient, m: string): TaintedString =
|
proc send*(ftp: PFTPClient, m: string): TaintedString =
|
||||||
## Send a message to the server, and wait for a primary reply.
|
## Send a message to the server, and wait for a primary reply.
|
||||||
|
|
@ -280,19 +280,18 @@ proc getLines(ftp: PFTPClient, async: bool = false): bool =
|
||||||
if ftp.dsockConnected:
|
if ftp.dsockConnected:
|
||||||
var r = TaintedString""
|
var r = TaintedString""
|
||||||
if ftp.isAsync:
|
if ftp.isAsync:
|
||||||
if ftp.asyncDSock.recvLine(r):
|
if ftp.asyncDSock.readLine(r):
|
||||||
if r.string == "":
|
if r.string == "":
|
||||||
ftp.dsockConnected = false
|
ftp.dsockConnected = false
|
||||||
else:
|
else:
|
||||||
ftp.job.lines.add(r.string & "\n")
|
ftp.job.lines.add(r.string & "\n")
|
||||||
else:
|
else:
|
||||||
assert(not async)
|
assert(not async)
|
||||||
if ftp.dsock.recvLine(r):
|
ftp.dsock.readLine(r)
|
||||||
if r.string == "":
|
if r.string == "":
|
||||||
ftp.dsockConnected = false
|
ftp.dsockConnected = false
|
||||||
else:
|
else:
|
||||||
ftp.job.lines.add(r.string & "\n")
|
ftp.job.lines.add(r.string & "\n")
|
||||||
else: OSError()
|
|
||||||
|
|
||||||
if not async:
|
if not async:
|
||||||
var readSocks: seq[TSocket] = @[ftp.getCSock()]
|
var readSocks: seq[TSocket] = @[ftp.getCSock()]
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ proc parseChunks(s: TSocket, timeout: int): string =
|
||||||
while true:
|
while true:
|
||||||
var chunkSizeStr = ""
|
var chunkSizeStr = ""
|
||||||
var chunkSize = 0
|
var chunkSize = 0
|
||||||
if s.recvLine(chunkSizeStr, timeout):
|
s.readLine(chunkSizeStr, timeout)
|
||||||
var i = 0
|
var i = 0
|
||||||
if chunkSizeStr == "":
|
if chunkSizeStr == "":
|
||||||
httpError("Server terminated connection prematurely")
|
httpError("Server terminated connection prematurely")
|
||||||
|
|
@ -175,7 +175,7 @@ proc parseResponse(s: TSocket, getBody: bool, timeout: int): TResponse =
|
||||||
while True:
|
while True:
|
||||||
line = ""
|
line = ""
|
||||||
linei = 0
|
linei = 0
|
||||||
if s.recvLine(line, timeout):
|
s.readLine(line, timeout)
|
||||||
if line == "": break # We've been disconnected.
|
if line == "": break # We've been disconnected.
|
||||||
if line == "\c\L":
|
if line == "\c\L":
|
||||||
fullyRead = true
|
fullyRead = true
|
||||||
|
|
@ -207,7 +207,6 @@ proc parseResponse(s: TSocket, getBody: bool, timeout: int): TResponse =
|
||||||
linei += skipWhitespace(line, linei)
|
linei += skipWhitespace(line, linei)
|
||||||
|
|
||||||
result.headers[name] = line[linei.. -1]
|
result.headers[name] = line[linei.. -1]
|
||||||
else: SocketError(s)
|
|
||||||
if not fullyRead:
|
if not fullyRead:
|
||||||
httpError("Connection was closed before full request has been made")
|
httpError("Connection was closed before full request has been made")
|
||||||
if getBody:
|
if getBody:
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,7 @@ proc poll*(irc: PIRC, ev: var TIRCEvent,
|
||||||
var socks = @[irc.sock]
|
var socks = @[irc.sock]
|
||||||
var ret = socks.select(timeout)
|
var ret = socks.select(timeout)
|
||||||
if socks.len() == 0 and ret != 0:
|
if socks.len() == 0 and ret != 0:
|
||||||
if irc.sock.recvLine(line):
|
irc.sock.readLine(line)
|
||||||
ev = irc.processLine(line.string)
|
ev = irc.processLine(line.string)
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
|
|
@ -380,7 +380,7 @@ proc handleConnect(s: PAsyncSocket, irc: PAsyncIRC) =
|
||||||
|
|
||||||
proc handleRead(s: PAsyncSocket, irc: PAsyncIRC) =
|
proc handleRead(s: PAsyncSocket, irc: PAsyncIRC) =
|
||||||
var line = "".TaintedString
|
var line = "".TaintedString
|
||||||
var ret = s.recvLine(line)
|
var ret = s.readLine(line)
|
||||||
if ret:
|
if ret:
|
||||||
if line == "":
|
if line == "":
|
||||||
var ev: TIRCEvent
|
var ev: TIRCEvent
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,6 @@
|
||||||
## For SSL support this module relies on OpenSSL. If you want to
|
## For SSL support this module relies on OpenSSL. If you want to
|
||||||
## enable SSL, compile with ``-d:ssl``.
|
## enable SSL, compile with ``-d:ssl``.
|
||||||
|
|
||||||
when not defined(ssl):
|
|
||||||
{.error: "The SMTP module should be compiled with SSL support. Compile with -d:ssl."}
|
|
||||||
|
|
||||||
import sockets, strutils, strtabs, base64, os
|
import sockets, strutils, strtabs, base64, os
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -54,16 +51,11 @@ proc debugSend(smtp: TSMTP, cmd: string) =
|
||||||
|
|
||||||
proc debugRecv(smtp: var TSMTP): TaintedString =
|
proc debugRecv(smtp: var TSMTP): TaintedString =
|
||||||
var line = TaintedString""
|
var line = TaintedString""
|
||||||
var ret = False
|
smtp.sock.readLine(line)
|
||||||
ret = smtp.sock.recvLine(line)
|
|
||||||
|
|
||||||
if ret:
|
|
||||||
if smtp.debug:
|
if smtp.debug:
|
||||||
echo("S:" & line.string)
|
echo("S:" & line.string)
|
||||||
return line
|
return line
|
||||||
else:
|
|
||||||
OSError()
|
|
||||||
return TaintedString""
|
|
||||||
|
|
||||||
proc quitExcpt(smtp: TSMTP, msg: string) =
|
proc quitExcpt(smtp: TSMTP, msg: string) =
|
||||||
smtp.debugSend("QUIT")
|
smtp.debugSend("QUIT")
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,8 @@ Changes affecting backwards compatibility
|
||||||
-----------------------------------------
|
-----------------------------------------
|
||||||
|
|
||||||
- ``shared`` is a keyword now.
|
- ``shared`` is a keyword now.
|
||||||
|
- Deprecated ``sockets.recvLine`` and ``asyncio.recvLine``, added
|
||||||
|
``readLine`` instead.
|
||||||
|
|
||||||
|
|
||||||
Compiler Additions
|
Compiler Additions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue