Hi, Ryan,

Sorry it took so long to answer, I have been investigating this issue,
and it is not a WSAPI problem, as I can reproduce it with this minimal
script:

----
#!/usr/bin/lua

require "lfcgi"

while lfcgi.accept() >= 0 do
  lfcgi.stdout:write("Status: 200 Ok\r\n")
  lfcgi.stdout:write("Content-Type: text/html\r\n\r\n")
  lfcgi.stdout:write("<html><body>Loading...</body></html>\r\n")
  --lfcgi.stdout:flush()
  os.execute("sleep 5")
  lfcgi.stdout:write('<script language="JavaScript">alert("foo");</script>')
end
---

I have tested both mod_fastcgi and mod_fcgid, and they have the same
behavior. Commenting out the call to flush also does nothing... the
FastCGI client library must be doing its own buffering, and ignoring
flush attempts (the lfcgi module just calls fflush and write on the
file handle that the FastCGI library gives it...).

Sorry for the bad news...

--
Fabio Mascarenhas


On Thu, Aug 19, 2010 at 10:24 AM, Ryan Pusztai <rpusz...@gmail.com> wrote:
> Hi Fabio,
>
> On Wed, Feb 10, 2010 at 5:20 PM, Fabio Mascarenhas <mascaren...@acm.org>
> wrote:
>>
>> On Wed, Feb 10, 2010 at 7:05 PM, Ryan Pusztai <rpusz...@gmail.com> wrote:
>>>
>>> Hi,
>>> I am using Orbit to write a web app and I have a very lengthy process of
>>> importing 500+ files into a database and I wanted to give the user feedback
>>> as this process continues. Is there a way to give the user updates?
>>> Even if it could be a "Please Wait..." message, then do the work, and
>>> then redirect to a complete status page. I know that web:redirect() exists,
>>> but I am having a tough time figuring out how to display a "please wait"
>>> message then starting the actual lengthy process.
>>> Sorry if this is a silly question, but I just can't seem to get it
>>> working.
>>
>> Ryan, Orbit does not buffer output by default, so you can't send a
>> response to the client and continue processing. You have to use a special
>> WSAPI rule to do that:
>> -------
>> local function wsapi_action(wsapi_env, param)
>>   local request = wsapi.request.new(wsapi_env)
>>   local response = coroutine.wrap(function ()
>>     coroutine.yield(my_waiting_html)
>>     ... do long operation ...
>>     coroutine.yield(rest of response)
>>   end)
>>   return 200, { ["Content-Type"] = "text/html" }, response
>> end
>> orbit_app:dispatch_wsapi(wsapi_action, "/foo/(%d+)")
>> --------
>> WSAPI's request object is pretty similar to Orbit's web object, but
>> slightly different. Please see the WSAPI docs.
>
> So I updated to the latest Kepler (Orbit v2.1.0 -> 2.2.0, WSAPI v1.2 ->
> 1.3.xi) and now this is not working using fcgid in Apache2 on Ubuntu v8.04
> (Hardy). It works in Xavante. Any ideas?
> --
> Regards,
> Ryan
>
> _______________________________________________
> Kepler-Project mailing list
> Kepler-Project@lists.luaforge.net
> http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
> http://www.keplerproject.org/
>

_______________________________________________
Kepler-Project mailing list
Kepler-Project@lists.luaforge.net
http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
http://www.keplerproject.org/

Reply via email to