lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Nope, not using wsapi.

Reading from the socket is a good idea though, that would yield a string with all the form data in it (if I understand this correctly, it's been a while) which I could then parse the same way that xavante.httpd.getparams does.

2011/6/21 Ignacio Burgueño <ignaciob@inconcertcc.com>
On Tue, Jun 21, 2011 at 4:28 PM, Ross Andrews <ross.andrews@gmail.com> wrote:
I am writing a handler for the Xavante web server, to handle AJAX requests. It seems like I'm not able to access any parameters from a POST request, only GET request ones sent through the URL. Here's what I have:

function create_ajax_handler(fn)
    return function(req, res)
        res.headers["Content-Type"] = "text/plain"

        res.content = fn(req)
        return res
    end
end

Inside the function I pass in (fn), req.params is nil. I've tried adding xavante.httpd.getparams(req), which works fine and populates req.params with URL params, but seems to totally ignore post data.


Aren't you using wsapi? That would simplify things a lot.

If not, I think you need to read from the socket:

req.socket:receive( as_many_bytes_as_content_length_indicates )