Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null terminated string in Http request #3541

Closed
MSGhero opened this issue Nov 4, 2014 · 1 comment
Closed

Null terminated string in Http request #3541

MSGhero opened this issue Nov 4, 2014 · 1 comment

Comments

@MSGhero
Copy link

MSGhero commented Nov 4, 2014

When the raw bytes of an Http request callback include a 0x00 byte, the string which gets sent to the onData() function is terminated and the data is dropped. Ex:

var b = haxe.io.Bytes.alloc(5);
b.set(0,72); // H
b.set(1,97); // a
b.set(2,120); // x
b.set(3,0x00); // \0
b.set(4,0x101); // e
// important data

haxe.Log.trace(b.toString().length); // 3, "Hax"
haxe.Log.trace(b.toHex().length / 2); // 5+, "48 61 78 00 65 ..."

Obviously you can't do anything about \0 in strings, but the Http request callback should be worked with so it doesn't drop data. Right now it forces all data into a string, so there's nothing a user can do with the binary. flash.net.URLLoaderDataFormat gives you the option to get the raw binary instead of text for this reason among others.

Maybe have the request come in as binary data, and loop through it to form a string with each \0 dropped? Or make onData take a dynamic and output the Bytes directly.

Tested in (openfl) flash and js.

@andyli
Copy link
Member

andyli commented Nov 4, 2014

duplicate of #2586

@andyli andyli closed this as completed Nov 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants