Fixed recvLine deprecation warnings.

This commit is contained in:
Dominik Picheta 2013-04-14 01:00:38 +01:00
commit e3d097c4e9
6 changed files with 72 additions and 80 deletions

View file

@ -126,7 +126,7 @@ type
handleTask*: proc (s: PAsyncSocket) {.closure.}
lineBuffer: TaintedString ## Temporary storage for ``recvLine``
lineBuffer: TaintedString ## Temporary storage for ``readLine``
sendBuffer: string ## Temporary storage for ``send``
sslNeedAccept: bool
proto: TProtocol
@ -635,7 +635,7 @@ when isMainModule:
proc testRead(s: PAsyncSocket, no: int) =
echo("Reading! " & $no)
var data = ""
if not s.recvLine(data):
if not s.readLine(data):
OSError()
if data == "":
echo("Closing connection. " & $no)

View file

@ -124,7 +124,7 @@ template blockingOperation(sock: TSocket, body: stmt) {.immediate.} =
proc expectReply(ftp: PFTPClient): TaintedString =
result = TaintedString""
blockingOperation(ftp.getCSock()):
if not ftp.getCSock().recvLine(result): setLen(result.string, 0)
ftp.getCSock().readLine(result)
proc send*(ftp: PFTPClient, m: string): TaintedString =
## 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:
var r = TaintedString""
if ftp.isAsync:
if ftp.asyncDSock.recvLine(r):
if ftp.asyncDSock.readLine(r):
if r.string == "":
ftp.dsockConnected = false
else:
ftp.job.lines.add(r.string & "\n")
else:
assert(not async)
if ftp.dsock.recvLine(r):
ftp.dsock.readLine(r)
if r.string == "":
ftp.dsockConnected = false
else:
ftp.job.lines.add(r.string & "\n")
else: OSError()
if not async:
var readSocks: seq[TSocket] = @[ftp.getCSock()]

View file

@ -100,7 +100,7 @@ proc parseChunks(s: TSocket, timeout: int): string =
while true:
var chunkSizeStr = ""
var chunkSize = 0
if s.recvLine(chunkSizeStr, timeout):
s.readLine(chunkSizeStr, timeout)
var i = 0
if chunkSizeStr == "":
httpError("Server terminated connection prematurely")
@ -175,7 +175,7 @@ proc parseResponse(s: TSocket, getBody: bool, timeout: int): TResponse =
while True:
line = ""
linei = 0
if s.recvLine(line, timeout):
s.readLine(line, timeout)
if line == "": break # We've been disconnected.
if line == "\c\L":
fullyRead = true
@ -207,7 +207,6 @@ proc parseResponse(s: TSocket, getBody: bool, timeout: int): TResponse =
linei += skipWhitespace(line, linei)
result.headers[name] = line[linei.. -1]
else: SocketError(s)
if not fullyRead:
httpError("Connection was closed before full request has been made")
if getBody:

View file

@ -345,7 +345,7 @@ proc poll*(irc: PIRC, ev: var TIRCEvent,
var socks = @[irc.sock]
var ret = socks.select(timeout)
if socks.len() == 0 and ret != 0:
if irc.sock.recvLine(line):
irc.sock.readLine(line)
ev = irc.processLine(line.string)
result = true
@ -380,7 +380,7 @@ proc handleConnect(s: PAsyncSocket, irc: PAsyncIRC) =
proc handleRead(s: PAsyncSocket, irc: PAsyncIRC) =
var line = "".TaintedString
var ret = s.recvLine(line)
var ret = s.readLine(line)
if ret:
if line == "":
var ev: TIRCEvent

View file

@ -28,9 +28,6 @@
## For SSL support this module relies on OpenSSL. If you want to
## 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
type
@ -54,16 +51,11 @@ proc debugSend(smtp: TSMTP, cmd: string) =
proc debugRecv(smtp: var TSMTP): TaintedString =
var line = TaintedString""
var ret = False
ret = smtp.sock.recvLine(line)
smtp.sock.readLine(line)
if ret:
if smtp.debug:
echo("S:" & line.string)
return line
else:
OSError()
return TaintedString""
proc quitExcpt(smtp: TSMTP, msg: string) =
smtp.debugSend("QUIT")

View file

@ -35,6 +35,8 @@ Changes affecting backwards compatibility
-----------------------------------------
- ``shared`` is a keyword now.
- Deprecated ``sockets.recvLine`` and ``asyncio.recvLine``, added
``readLine`` instead.
Compiler Additions