Just
Just copied to clipboard
print httpbody as a string?
I'm trying to upload a file using Just but getting a 500 from my server which I want to debug. I'm able to see the status code and the request headers but not the http body. The description of the body shows there is content (from the debugger):
(lldb) po String(r.request!.httpBody!)
"3174935 bytes"
but the actual content won't print:
(lldb) po NSString(data: r.request!.httpBody!, encoding: String.Encoding.utf8.rawValue)
nil
Any thoughts on how to look at this? I'm basically trying to make sure the body is properly formed and the source code looks fine.
My code looks like this:
Just.post("...", files: [fileName: HTTPFile.url(localFileUrl, "image/png")]) { r in
if r.ok {
print(r.json)
} else {
print(r.statusCode)
print(r.request?.httpBody)
}
}
where the localFileUrl is:
file:///var/mobile/Containers/Data/Application/7185716F-904E-4404-9BBD-F09EDCD4B5DD/Documents/2963391223.png
if let data = r.request?.httpBody {
print(NSString(data: data, encoding: String.Encoding.utf8.rawValue))
}