diff options
author | Araq <rumpf_a@web.de> | 2014-01-18 01:16:45 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-01-18 01:16:45 +0100 |
commit | 36afdca87f3757c8468cbfa622de693447df7e07 (patch) | |
tree | 3b739b667574c12dea389a17d9d84291fd355463 /lib/pure | |
parent | 5073914b8697a9fd1dc38bebef434b50850f2861 (diff) | |
parent | 3f8bfb1e988322ab60cc54184d63a00906260665 (diff) | |
download | Nim-36afdca87f3757c8468cbfa622de693447df7e07.tar.gz |
resolved conflicts with master
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/asyncio.nim | 7 | ||||
-rw-r--r-- | lib/pure/httpclient.nim | 3 | ||||
-rw-r--r-- | lib/pure/os.nim | 8 | ||||
-rw-r--r-- | lib/pure/unicode.nim | 4 |
4 files changed, 18 insertions, 4 deletions
diff --git a/lib/pure/asyncio.nim b/lib/pure/asyncio.nim index c4a07d751..3c2a5c17a 100644 --- a/lib/pure/asyncio.nim +++ b/lib/pure/asyncio.nim @@ -233,8 +233,11 @@ proc asyncSockHandleWrite(h: PObject) = let sock = PAsyncSocket(h) try: let bytesSent = sock.socket.sendAsync(sock.sendBuffer) - assert bytesSent > 0 - if bytesSent != sock.sendBuffer.len: + if bytesSent == 0: + # Apparently the socket cannot be written to. Even though select + # just told us that it can be... This used to be an assert. Just + # do nothing instead. + elif bytesSent != sock.sendBuffer.len: sock.sendBuffer = sock.sendBuffer[bytesSent .. -1] elif bytesSent == sock.sendBuffer.len: sock.sendBuffer = "" diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim index 2c0e7b835..bb9835fe7 100644 --- a/lib/pure/httpclient.nim +++ b/lib/pure/httpclient.nim @@ -220,9 +220,8 @@ proc parseResponse(s: TSocket, getBody: bool, timeout: int): TResponse = inc(linei, le) if line[linei] != ':': httpError("invalid headers") inc(linei) # Skip : - linei += skipWhitespace(line, linei) - result.headers[name] = line[linei.. -1] + result.headers[name] = line[linei.. -1].strip() if not fullyRead: httpError("Connection was closed before full request has been made") if getBody: diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 504343d67..448ecc1e3 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -387,6 +387,14 @@ proc existsDir*(dir: string): bool {.rtl, extern: "nos$1", tags: [FReadDir].} = var res: TStat return stat(dir, res) >= 0'i32 and S_ISDIR(res.st_mode) +proc fileExists*(filename: string): bool {.inline.} = + ## Synonym for existsFile + existsFile(filename) + +proc dirExists*(dir: string): bool {.inline.} = + ## Synonym for existsDir + existsDir(dir) + proc getLastModificationTime*(file: string): TTime {.rtl, extern: "nos$1".} = ## Returns the `file`'s last modification time. when defined(posix): diff --git a/lib/pure/unicode.nim b/lib/pure/unicode.nim index 37a64a8f3..6e73eea3f 100644 --- a/lib/pure/unicode.nim +++ b/lib/pure/unicode.nim @@ -132,6 +132,10 @@ proc toUTF8*(c: TRune): string {.rtl, extern: "nuc$1".} = result = newString(1) result[0] = chr(i) +proc `$`*(rune: TRune): string = + ## converts a rune to a string + rune.toUTF8 + proc `$`*(runes: seq[TRune]): string = ## converts a sequence of runes to a string result = "" |