Thanks very much for the reply. Unfortunately end is a keyword in Lua and
it looks from the API that an alternative has not been implemented.
writeHead(302...) without an end hangs the page loading so that won't work
by itself.
I have it serving up a new page depending on POST data, but the URL is not
updating in the browser I assume because it isn't redirected. It would be
interesting to hear what the correct procedure is for this.
On Tuesday, 2 February 2016 23:09:54 UTC, alfred wrote:
>
> res.writeHead(302, {Location = root..req.uri.pathname})
> res.end()
>
> Will this work?
>
>
> On Tuesday, 2 February 2016 04:50:52 UTC+8, Paul Reilly wrote:
>>
>> Hi
>>
>> I am beginning to play with Luvit and have one stumbling block left to
>> finish an app, which is to redirect after receiving POST data. I am
>> receiving the data fine, but don't know how to redirect it? Could somebody
>> give me a nudge in the right direction?
>>
>> In http.createServer I have...
>>
>> if req.method=="POST" then
>> local b={}
>> print("request is POST")
>> req:on("data", function(chunk)
>> if #chunk>100 then
>> return
>> else
>> table.insert(b,chunk)
>> end
>> end)
>>
>> req:on("end", function ()
>> if #b>0 then
>> req.uri.pathname=processPOST(b,req.uri.pathname)
>> --res.send({redirect=root..req.uri.pathname})
>> --req.redirect(req.uri.pathname)
>> --req:redirect(req.uri.pathname)
>> end
>> end)
>>
>> Thanks for any advice,
>>
>> Cheers
>>
>> Paul
>>
>
--
You received this message because you are subscribed to the Google Groups
"luvit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.