CCaptchaAction & local domains

Hi there, this is my first post! :slight_smile:

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… :wink:

Thanks in advance,


end() just finishes the script execution so that there is no additional output to the screen, but all that has been sent to the screen before it, should be there…

Did you chech the yii requirements on localhost… captcha needs the GD extension with FreeType support

Yep, checkRequirements returns true and I’ve also checked manually: gd is correctly installed and the TTF also. By the way, when I change the call from end() to end(0, false) the image is properly generated.

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?

it’s hard to say what could be the problem without having and debuging the code… you should check this with some tools like firebug for firefox to see if any data and what data is returned.

Sorted out! :)

I’ve read this thread (hteeteepee:// and found it was related to xdebug too… So I upgraded it and the problem disappeared!

Thanks anyway,