[klone-users] issue with response_redirect after processing file download

thomas fossati tho at koanlogic.com
Thu Nov 19 13:42:18 EST 2009


Hi Moises,

On Nov 12, 2009, at 11:58 PM, moises acuna wrote:
>    while ((q_rb = fread(the_buf, 1, sizeof the_buf, target)) > 0)
>                   (void) io_write(out, the_buf, q_rb);

if "the_buf" is big enough, the io_write() will force the HTTP  
response to be pushed out right now with status set to 200 - i.e. the  
default.

>    fr_setMessage(session, "Transfer executed successfully. File  
> downloaded!.");
>    response_redirect(response, "systemfiles.kl1");  // ***

At this point you are setting status to 302 but it's too late for it  
to be included in the header because the header is already gone with  
its payload ("the_buf").

> ***: here the I would like to redirect to systemfiles.kl1 but it  
> doesn't
>      if I manually refresh the page the "Transfer executed succ..."  
> message is shown
>      I need to redirect from the download page to show this message
>     automatically (and othe stuff, like reenable some buttons) when  
> the download
>     is complete.
>   the download is executed fine , it's just the redirect.
>   the io_write function changes the response values I think.


I think that with a small "the_buf" you could have the chance to see  
your response redirected, but in that case there would be no download  
because the browser would obey the 302, immediately trying to GET / 
systemfiles.kl1.

Hope it helps.

ciao, t.




More information about the klone-users mailing list