CCaptchaAction & local domains
Posted 02 August 2012 - 10:46 PM
I'm still quite new to Yii but everything has been going well so far except one thing that I can't get. I've noticed it once but by that time and couldn't halt and investigate since it was not blocking in production.
In CCaptchaAction, at the end of the "run" method there's a call to "Yii::app()->end()" which ends up calling PHP's "exit" function since the second parameter is true by default (see implementation of CApplication#end).
When I run my code (which is really really close to the captcha example's) on a live domain/host it runs like a charm, but when I'm under development cycle I'm running it on a local VM with a custom domain name like "stuff" (one single word, declared in my local Windows hosts file) the captcha image is not sent to the browser and I'm getting error messages like «Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.» (Chrome).
In facts, I'm not sure why the image is sent out to the browser in production since the implementation makes that call to the "exit" function. I've tried to see if I could change the direct call to "end()" for a call like "end(0, false)" so that it doesn't exit and it actually flushes the image to the browser, which is logical to me, and it works!
What I can't understand is why it works in production - I'm more comfortable with that call to "end(0, false)", it makes more sense to me but I'm surely wrong.
So, well, I'd really appreciate your help! I'm using Yii 1.1.9 and a standard LAMP stack (VirtualBox, Fedora, httpd). Implied URL is like: "hteeteepee://stuff/index.php?r=registration/captcha&v=501b47646a064" and "captcha" points to the original CCaptchaAction class.
Please tell me if you need more details. I think everything relevant is here already but it's late and I may have missed something... ;)
Thanks in advance,
Posted 03 August 2012 - 02:33 AM
Did you chech the yii requirements on localhost... captcha needs the GD extension with FreeType support
Posted 03 August 2012 - 12:44 PM
Apart from that you're definitely right and I thought about it on my way to the bed yesterday: as soon as header is called something is flushed out so I should get some bits of an HTTP response on the browser side anyway. Or maybe it somehow gets into an HTTP buffer which is dismissed at the end for some reason?
Posted 03 August 2012 - 05:07 PM