parent
64e8f050e1
commit
e5478b32a8
1 changed files with 13 additions and 0 deletions
|
|
@ -175,6 +175,8 @@
|
||||||
## let client = newHttpClient(maxRedirects = 0)
|
## let client = newHttpClient(maxRedirects = 0)
|
||||||
##
|
##
|
||||||
|
|
||||||
|
include "system/inclrtl"
|
||||||
|
|
||||||
import net, strutils, uri, parseutils, base64, os, mimetypes,
|
import net, strutils, uri, parseutils, base64, os, mimetypes,
|
||||||
math, random, httpcore, times, tables, streams, std/monotimes
|
math, random, httpcore, times, tables, streams, std/monotimes
|
||||||
import asyncnet, asyncdispatch, asyncfile
|
import asyncnet, asyncdispatch, asyncfile
|
||||||
|
|
@ -297,6 +299,17 @@ proc newMultipartData*: MultipartData =
|
||||||
## Constructs a new ``MultipartData`` object.
|
## Constructs a new ``MultipartData`` object.
|
||||||
MultipartData(content: @[])
|
MultipartData(content: @[])
|
||||||
|
|
||||||
|
|
||||||
|
proc `$`*(data: MultipartData): string {.since: (1, 1).} =
|
||||||
|
## convert MultipartData to string so it's human readable when echo
|
||||||
|
## see https://github.com/nim-lang/Nim/issues/11863
|
||||||
|
const prefixLen = "Content-Disposition: form-data; ".len
|
||||||
|
for pos, item in data.content:
|
||||||
|
result &= "------------------------------ "
|
||||||
|
result.addInt pos
|
||||||
|
result &= " ------------------------------\n"
|
||||||
|
result &= item[prefixLen .. item.high]
|
||||||
|
|
||||||
proc add*(p: var MultipartData, name, content: string, filename: string = "",
|
proc add*(p: var MultipartData, name, content: string, filename: string = "",
|
||||||
contentType: string = "") =
|
contentType: string = "") =
|
||||||
## Add a value to the multipart data. Raises a `ValueError` exception if
|
## Add a value to the multipart data. Raises a `ValueError` exception if
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue