Post your best Lua script examples here

User avatar
By rwkiii
#40372 This solution seems to be very elegant with the exception that it doesn't work on iPhones/Safari. Of course, all I get is a blank white page on my iPhone. There are online iPhone simulators which would probably show the same symptom.

Has anyone coded a solution for this problem?
User avatar
By rwkiii
#40376
andrew melvin wrote:Your code also does not work for apple browsers... I figured out after a huge amount of head scratching why this it... it is true for safari, and browsers on iPad and phone. I kind of think having it work is fairly important...

what i noticed is that for POST requests... apple browsers send the first POST request, but it is empty... the second POST request contains nothing but the data, no headers... this is different from chrome and firefox where the payload is within the first POST request. I used a variable that was made true to scan the second POST request if the first one failed the string match!


Andrew, I know others have tugged at you as well - but I wondered if you are able to show how you overcome the Safari double POST issue. I've been trying to figure out a solution but not making any progress.

Thank you either way!
User avatar
By rfahey
#61192 Resurrecting an old thread because I didn't see a solution posted...

The issue seems to be a lack of header information sent in the request. Safari is very strict about the content you send, whereas Chrome (and most browsers for that matter) will kind of "fake it" if they don't receive exactly the correct information that they're looking for.

So to get this to work in Safari, just make sure to send a header before your page buffer:

client:send("HTTP/1.1 200 OK\r\n");
client:send("Content-type: text/html\r\n");
client:send("Connection: close\r\n\r\n");

HTH