Just icon indicating copy to clipboard operation
Just copied to clipboard

Allow non-filename HTTPFile.text

Open pine opened this issue 7 years ago • 0 comments

Hello 😄 I'm using Just HTTP client in my product, but I found some problem.

I tried to scrape Slack web site with Just. In particular, I attempted to send the following request to Slack, and it failed.

var files: [String: HTTPFile] = [:]
files["name"] = .text("name", "name"", nil)
files["crumb"] = .text("crumb", "xxxxxx", nil)
files["mode"] = .text("mode", "data", nil)
files["add"] = .text("add", "1", nil)
files["img"] = .data("emoji.png", data, "image/png")

Just.post("https://my-team.slack.com/customize/emoji", files: files)

I was in great trouble, trial and error, and I found out that the cause is as follows.

let dispose = "Content-Disposition: form-data; name=\"\(k)\"; filename=\"\(filename)\"\r\n"

Content-Disposition header contained filename filed was not accepted at Slack. So that, I've patched like this PR, and it works.

Thank you.

pine avatar Sep 18 '17 20:09 pine