diff --git a/chronos/apps/http/httpclient.nim b/chronos/apps/http/httpclient.nim index 83d5623..f63b24c 100644 --- a/chronos/apps/http/httpclient.nim +++ b/chronos/apps/http/httpclient.nim @@ -1039,7 +1039,7 @@ proc send*(request: HttpClientRequestRef): Future[HttpClientResponseRef] {. except CancelledError as exc: request.setError(newHttpInterruptError()) raise exc - except AsyncStreamError as exc: + except AsyncStreamError: let error = newHttpWriteError("Could not send request headers") request.setError(error) raise error @@ -1084,7 +1084,7 @@ proc open*(request: HttpClientRequestRef): Future[HttpBodyWriter] {. except CancelledError as exc: request.setError(newHttpInterruptError()) raise exc - except AsyncStreamError as exc: + except AsyncStreamError: let error = newHttpWriteError("Could not send request headers") request.setError(error) raise error @@ -1208,7 +1208,7 @@ proc getBodyBytes*(response: HttpClientResponseRef): Future[seq[byte]] {. await reader.closeWait() response.setError(newHttpInterruptError()) raise exc - except AsyncStreamError as exc: + except AsyncStreamError: if not(isNil(reader)): await reader.closeWait() let error = newHttpReadError("Could not read response") @@ -1233,7 +1233,7 @@ proc getBodyBytes*(response: HttpClientResponseRef, await reader.closeWait() response.setError(newHttpInterruptError()) raise exc - except AsyncStreamError as exc: + except AsyncStreamError: if not(isNil(reader)): await reader.closeWait() let error = newHttpReadError("Could not read response") @@ -1256,7 +1256,7 @@ proc consumeBody*(response: HttpClientResponseRef): Future[int] {.async.} = await reader.closeWait() response.setError(newHttpInterruptError()) raise exc - except AsyncStreamError as exc: + except AsyncStreamError: if not(isNil(reader)): await reader.closeWait() let error = newHttpReadError("Could not read response") diff --git a/chronos/apps/http/httpcommon.nim b/chronos/apps/http/httpcommon.nim index 0423f22..860a7a7 100644 --- a/chronos/apps/http/httpcommon.nim +++ b/chronos/apps/http/httpcommon.nim @@ -7,7 +7,7 @@ # Apache License, version 2.0, (LICENSE-APACHEv2) # MIT license (LICENSE-MIT) import std/[strutils, uri] -import stew/[results, endians2], httputils +import stew/results, httputils import ../../asyncloop, ../../asyncsync import ../../streams/[asyncstream, boundstream] export asyncloop, asyncsync, results, httputils, strutils @@ -125,9 +125,8 @@ iterator queryParams*(query: string, if len(k) > 0: let v = if len(items) > 1: items[1] else: "" if CommaSeparatedArray in flags: - let key = decodeUrl(k) for av in decodeUrl(v).split(','): - yield (k, av) + yield (decodeUrl(k), av) else: yield (decodeUrl(k), decodeUrl(v)) @@ -249,48 +248,3 @@ func stringToBytes*(src: openArray[char]): seq[byte] = dst else: default - -proc dumpHex*(pbytes: openArray[byte], groupBy = 1, ascii = true): string = - ## Get hexadecimal dump of memory for array ``pbytes``. - var res = "" - var offset = 0 - var ascii = "" - - while offset < len(pbytes): - if (offset mod 16) == 0: - res = res & toHex(uint64(offset)) & ": " - - for k in 0 ..< groupBy: - let ch = pbytes[offset + k] - ascii.add(if ord(ch) > 31 and ord(ch) < 127: char(ch) else: '.') - - let item = - case groupBy: - of 1: - toHex(pbytes[offset]) - of 2: - toHex(uint16.fromBytes(pbytes.toOpenArray(offset, len(pbytes) - 1))) - of 4: - toHex(uint32.fromBytes(pbytes.toOpenArray(offset, len(pbytes) - 1))) - of 8: - toHex(uint64.fromBytes(pbytes.toOpenArray(offset, len(pbytes) - 1))) - else: - "" - res.add(item) - res.add(" ") - offset = offset + groupBy - - if (offset mod 16) == 0: - res.add(" ") - res.add(ascii) - ascii.setLen(0) - res.add("\p") - - if (offset mod 16) != 0: - let spacesCount = ((16 - (offset mod 16)) div groupBy) * - (groupBy * 2 + 1) + 1 - res = res & repeat(' ', spacesCount) - res = res & ascii - - res.add("\p") - res diff --git a/chronos/apps/http/multipart.nim b/chronos/apps/http/multipart.nim index 971c000..2ec869a 100644 --- a/chronos/apps/http/multipart.nim +++ b/chronos/apps/http/multipart.nim @@ -604,7 +604,6 @@ proc beginPart*(mpw: MultiPartWriterRef, name: string, ## output stream. ## ## Note: `filename` and `name` arguments could be only ASCII strings. - const ContentDisposition = "Content-Disposition" doAssert(mpw.kind == MultiPartSource.Stream) doAssert(mpw.state in {MultiPartWriterState.MessageStarted, MultiPartWriterState.PartFinished})