Corona Simulator build 2016.2831 (Windows)
First, the code:
[lua]
local typeRequest = “calendar”
local currentDate = “2016-03-05”
local settings = {type=typeRequest,date=currentDate}
local params = {}
local headers = {}
– if (system.getInfo(“environment”) == “simulator”) then
headers[“User-Agent”] = “app request”
params.headers = headers
– end
params.body = “type=” … settings.type … “&date=” … settings.date
print("Parameter String: " … params.body)
print("Parameter header: " … params.headers[“User-Agent”])
network.download ( dataURL, “POST”, calendarListener, params, “latest.txt”, system.TemporaryDirectory )[/lua]
The problem:
When I run this code in the Windows simulator, it works as expected. It sends the calendar request and the date as well as the header. The PHP webserver receives all of the info ($_POST shows the posted info) and responds as expected. When I build for Android and install on a device (Nexus 6 with Android 6), the webserver receives the user agent, but does not receive the params.body ($_POST variable shows that it received nothing). Both on the simulator and on the device, when I print params.body and params.headers as shown in the code, the relevant information is displayed as expected, but when the code is running on the device, the params.body info never makes it to the webserver. The device DOES post the calendar request properly when I uncomment the ‘if’ block. However, I do need the user agent info so (the default setting does not pass user agent info) this isn’t a solution. The documentation for network.request seems pretty straightforward, but if I have missed something/doing something wrong I hope a fresh set of eyes can spot what I am not seeing!
Any thoughts or suggestions??
Thank you!