api-content.dropbox.com
Trying to access this url using:
http.get("https://api-content.dropbox.com/1/files_put/dropbox/") --or: http.post("https://api-content.dropbox.com/1/files_put/dropbox/")or any other variation just does not work. It will just return nil.
multipart/form-data
I saw this and, like a fool, wondered if I could use multipart/form-data to submit forms via Lua:
local FileName = "Test.lua" local File = fs.open(FileName, "r") local FileContents = File.readAll() File.close() local URL = "http://echo.200please.com/" --"http://httpbin.org/post" local Boundary = "79abff9df9a846709f00eeccb840e55d" -- Should be random local Headers = { ["Content-Type"] = "multipart/form-data; boundary="..Boundary } Boundary = '--'..Boundary local PostData = Boundary ..'\r\n' PostData = PostData .. 'Content-Disposition: form-data; name="uploadedfile"; filename="'..FileName..'"\r\n' PostData = PostData .. "Content-Type: text/plain; charset=utf-8\r\n\r\n" -- You need a lot. PostData = PostData .. FileContents .. "\r\n" -- Include file PostData = PostData .. Boundary .. '--\r\n' -- Final boundry Headers['Content-Length'] = #PostData local Result = http.post(URL, PostData, Headers) local Out = Result.readAll() print(Out)
Here the server does not even respond, I just get stuck on the http.post call, nothing happens. Any ideas what is happening?
My theory is that the server is still waiting for content and so the connection does not close. I can't prove this though.
Edit: I'm using wireshark to monitor my network, it looks as if nothing is even leaving my computer??? Maybe I'm misreading the figures.
Edited by SquidDev, 30 May 2014 - 03:32 PM.