NetConnection.Call.BadVersion and Byte Order Mark (BOM)
| Project: | AMFPHP |
| Version: | 6.x-1.0-beta1 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Hello everybody.
I am facing a strange problem that prevents me from connecting to Drupal from Flash.
When I issue this from Flash
var drupal:NetConnection = new NetConnection();
drupal.objectEncoding = ObjectEncoding.AMF3;
drupal.connect( 'services/amfphp' );I am getting "NetConnection.Call.BadVersion". Using ServiceCapture to save the server's response to a file I see that there is a BOM \xEF\xBB\BF in front of the response. When I manually remove the BOM from this file and by using the ServiceCapture's feature "Map URL to file", I am replacing the server's response with the edited file, Flash connects normally.
Where this BOM is coming from?
I have tried all possible combinations on $gateway->setCharsetHandler("xxx", "yyy", "zzz"); in amfphp.module with no luck.
I have searched extensively on google.com, amfphp.org, drupal.org with various terms I came up with, but everyone is hinting on hidden BOM's in front of <?php tags placed there from various editors. Well this is not the case, I have looked in all of my installation's files with a hex editor and there is nowhere a BOM.
I have traced with ActiveStateKomodo the whole response generation line by line. The final code that actually sends the response is in sites/all/modules/amfphp/amfphp/core/amf/app/Gateway.php at line 247
print($output); // flush the binary data
The sent output is
\x00\x00\x00\x01\x00\x12AppendToGatewayUrl\x00\x00\x00\x00C\x02\x00@?SESS6725e8504a10b3249433133c79f307ac=lpnh9mpnsqc70qa0metfi4t687\x00\x01\x00\x0B/1/onResult\x00\x04null\x00\x00\x00™\x03\x00\x06sessid\x02\x00\x1Alpnh9mpnsqc70qa0metfi4t687\x00\x04user\x03\x00\x06userid\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08hostname\x02\x00127.0.0.1\x00\x05roles\x08\x00\x00\x00\x01\x00\x011\x02\x00\x0Eanonymous user\x00\x00 \x00\x07session\x02\x00\x00\x00\x05cache\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
so no BOM here...
I also tried on various systems, CentOs/FreeBSD/WinXP-Apache/Lighttp-PHP 5.2.1 /PHP 5.2.11. Same thing everywhere.
So where this damn BOM is getting added? I have been searching for days without any success. I have run out of new ideas to try and my last resort before quitting the Flash-Drupal communication through AMF is posting here.
Any help/hint/advice will be much appreciated.
