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

fixes non buffers in data event issue #75

Closed
wants to merge 1 commit into from
Closed

fixes non buffers in data event issue #75

wants to merge 1 commit into from

Conversation

dscape
Copy link

@dscape dscape commented Sep 9, 2011

[main,test-body] fixes non buffers in data event issue when setting encoding manually

…ncoding manually

* added unit test to test/test-body.js
* fixed bug by checking if chunk is buffer in main.js
* fixes #74
@mikeal
Copy link
Member

mikeal commented Sep 9, 2011

i think i see what the problem is. if you setEncoding the chunks won't be buffers, they'll be strings. the code @issacs wrote to merge the array together assumes buffers.

it would be lower impact to add this isBuffer check to where it gets concatenated rather than creating new buffers around each chunk if they are already encoded in to a string.

@dscape
Copy link
Author

dscape commented Sep 9, 2011

I think I tried what you are suggesting first @mikeal but then the string was being trimmed? Then I thought it oughta be because of the length variable that was being aggregated, so as a simple fix moved it up.

@mikeal mikeal closed this Sep 9, 2011
@mikeal
Copy link
Member

mikeal commented Sep 9, 2011

Fixed in a different commit.

@dscape
Copy link
Author

dscape commented Sep 11, 2011

@mikeal I think you forgot the test, will help prevent that future improvements re-introduce the bug

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

Successfully merging this pull request may close these issues.

Exception thrown when you change encoding and get a non-buffer in the data event
2 participants