ufront / ufront-mvc

The core MVC framework that powers ufront
MIT License
17 stars 15 forks source link

ByteResult on nodejs #36

Closed kevinresol closed 8 years ago

kevinresol commented 8 years ago

It won't work when bytes are converted to string... https://github.com/ufront/ufront-mvc/blob/master/src/ufront/web/context/HttpResponse.hx#L194

then flush... https://github.com/ufront/ufront-mvc/blob/master/src/nodejs/ufront/web/context/HttpResponse.hx#L63

Need to use res.end(buffer, "binary")

jasononeil commented 8 years ago

Thanks for bringing it up.

So are you saying instead of converting bytes to a string, we should directly use res.end(bytes, "binary") ?

I haven't got a nodejs project that uses this at the moment, so if you know what the code should be it will save me some time figuring it out :)

kevinresol commented 8 years ago

I do have some code on hand, but it is a bit messy. I will try to tidy up and make a PR later.

kevinresol commented 8 years ago

I am doing some conversion like this, which I think is not necessary:

var buffer = new js.node.Buffer([for(i in 0...bytes.length) bytes.get(i)]);
res.end(buffer, "binary");