Project Elbow: Magic Cookie + AS3 Plus is not PHP Dot

I woke up at 5 this morning.  I need to leave for work at 7, so I decided to do a little morning time rushing on Project Elbow.

My PHP service script was crashing because I used a + instead of a . to stick the content-length onto the end of the content-length header.

This is a common error I make when switching between Javascript or ActionScript 3 and PHP:

header(“Content-Length: ” + $contentLength );

This creates a header that’s just a number.  And that causes the fastCGI process to puke up the script and serve up status 500.

Should use string concatenation in PHP instead of number addition:

header(“Content-Length: ” . $contentLength );

Anyway, the URLStream class for some reason dispatches the HTTP Status code event after dispatching the progress event for data received, so the parser for the beginning on the output was crashing.  So, I added a “Magic Cookie”… It’s just an expected string of bytes that have to be at the beginning of output or the top of a file to display its type.  An error on the script side will never put out this cookie, so I know it’s nothing to be parsed further.

Also: Event bubbling is handy.

6:30.  Got to go.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.