-
Notifications
You must be signed in to change notification settings - Fork 59
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
Fix throwing error on request body without content-length and transfer-encoding #101
base: master
Are you sure you want to change the base?
Conversation
8b6a4ae
to
8d06737
Compare
Since the automated tests apparently aren't working, just to check, does Glancing at the code though, generally this library tries to parse everything it can (as opposed to Node's built-in one which throws errors if anything isn't exactly perfect, which of course causes problems when scraping various misbehaving websites, which is what at least brought me to using this library ^_^) - so can't we just parse the body in that case? Assuming you've got an actual case in the wild of getting a response like that from a server, is it not parseable? With no content-length nor explicit encoding, the body is probably just plain whatever the default normally is...? Not a big deal if it can't be parsed, throwing an error is at least better than getting stuck =). |
Oh, since the new code is throwing an error, it might not fit the pattern of that test file, so if it's not feasible to parse it, probably don't worry about adding a new test (but, please, make sure the existing tests still pass). |
Will check now! Thanks for the thoughtful response - it didn't seem super possible to do this any other way. |
Good call on the tests - looks like I needed to add a few more checks. |
@Jimbly this actually breaks the tests in a relatively bad way...
Because there's another request, which is out of standard. If you have ideas, please let me know! |
I added a few more conditions which would make it more durable, but without refactoring the test suite, I'm not sure how we could get this merged. |
What exactly does the the request you're trying to handle/parse that's causing trouble look like? |
In NodeJS, this is supposed to return a 400 bad request. |
That looks like it should be one good request (everything up to the |
Fixes what I was actually seeing in #100.