Thanks, the last one works without errors (no idea how I didn't see
finish() in the API and relate it to end() :) ). It doesn't redirect Chrome
or Firefox though. I'll have a play around and see if I can work out why.
On Thursday, 4 February 2016 00:00:48 UTC, Ryan Phillips wrote:
>
> Hey All,
>
> Paul, you will want to do something like:
>
> res:writeHead(302, {Location = 'somepath'})
> res:finish()
>
> Regards,
> Ryan
>
> On Wed, Feb 3, 2016, at 03:43 PM, Michal Kolodziejczyk GMAIL wrote:
>
>
> Hello,
> as far as Lua goes, the correct syntax would be:
> res['end']()
>
> I think that "POST redirect" depends on browser support. I do remember
> many years ago some browsers did redirect to the new location, but the
> POST content was not resent (so it was effectively redirecting original
> POST request to the new GET request).
> I have not tested it lately.
>
> Regards.
> miko
>
> On 03.02.2016 23:36, Paul Reilly wrote:
>
> 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] <javascript:>
> <mailto:[email protected] <javascript:>>.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> 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] <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
--
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.