diff options
author | Araq <rumpf_a@web.de> | 2018-08-13 17:27:44 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-08-13 17:27:44 +0200 |
commit | 420ed0596b8114c67275c4702fa3524ebd76e5eb (patch) | |
tree | f381eaedb04743a43faa1ded7e5d77ac5952ab3e /lib | |
parent | d60bb1b289c7914443a20b78bfb6c69f05184937 (diff) | |
download | Nim-420ed0596b8114c67275c4702fa3524ebd76e5eb.tar.gz |
fixes more nil handling regressions
Diffstat (limited to 'lib')
-rw-r--r-- | lib/deprecated/pure/actors.nim | 3 | ||||
-rw-r--r-- | lib/pure/httpclient.nim | 14 |
2 files changed, 8 insertions, 9 deletions
diff --git a/lib/deprecated/pure/actors.nim b/lib/deprecated/pure/actors.nim index 17321cc0e..451668825 100644 --- a/lib/deprecated/pure/actors.nim +++ b/lib/deprecated/pure/actors.nim @@ -43,7 +43,6 @@ type t: Thread[ptr Actor[In, Out]] PActor*[In, Out] = ptr Actor[In, Out] ## an actor -{.deprecated: [TTask: Task, TActor: Actor].} proc spawn*[In, Out](action: proc( self: PActor[In, Out]){.thread.}): PActor[In, Out] = @@ -168,7 +167,7 @@ proc terminate*[In, Out](a: var ActorPool[In, Out]) = for i in 0..<a.actors.len: join(a.actors[i]) when Out isnot void: close(a.outputs) - a.actors = nil + a.actors = @[] proc join*[In, Out](a: var ActorPool[In, Out]) = ## short-cut for `sync` and then `terminate`. diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim index a98779db3..0192e71e7 100644 --- a/lib/pure/httpclient.nim +++ b/lib/pure/httpclient.nim @@ -378,23 +378,23 @@ proc newMultipartData*: MultipartData = ## Constructs a new ``MultipartData`` object. MultipartData(content: @[]) -proc add*(p: var MultipartData, name, content: string, filename: string = nil, - contentType: string = nil) = +proc add*(p: var MultipartData, name, content: string, filename: string = "", + contentType: string = "") = ## Add a value to the multipart data. Raises a `ValueError` exception if ## `name`, `filename` or `contentType` contain newline characters. if {'\c','\L'} in name: raise newException(ValueError, "name contains a newline character") - if filename != nil and {'\c','\L'} in filename: + if {'\c','\L'} in filename: raise newException(ValueError, "filename contains a newline character") - if contentType != nil and {'\c','\L'} in contentType: + if {'\c','\L'} in contentType: raise newException(ValueError, "contentType contains a newline character") var str = "Content-Disposition: form-data; name=\"" & name & "\"" - if filename != nil: + if filename.len > 0: str.add("; filename=\"" & filename & "\"") str.add("\c\L") - if contentType != nil: + if contentType.len > 0: str.add("Content-Type: " & contentType & "\c\L") str.add("\c\L" & content & "\c\L") @@ -434,7 +434,7 @@ proc addFiles*(p: var MultipartData, xs: openarray[tuple[name, file: string]]): var contentType: string let (_, fName, ext) = splitFile(file) if ext.len > 0: - contentType = m.getMimetype(ext[1..ext.high], nil) + contentType = m.getMimetype(ext[1..ext.high], "") p.add(name, readFile(file), fName & ext, contentType) result = p |