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

Empty responses not handled properly #25

Closed
ronag opened this issue Jun 8, 2019 · 2 comments
Closed

Empty responses not handled properly #25

ronag opened this issue Jun 8, 2019 · 2 comments

Comments

@ronag
Copy link
Member

ronag commented Jun 8, 2019

Please see,

nodejs/node#28137

I'm unsure how to reproduce the issue with llhttp only. Problem occurs through Node.

@indutny
Copy link
Member

indutny commented Jun 8, 2019

👀

@indutny
Copy link
Member

indutny commented Jun 9, 2019

Work-in-progress fix:

diff --git a/src/llhttp/http.ts b/src/llhttp/http.ts
index 969bafc..83779c4 100644
--- a/src/llhttp/http.ts
+++ b/src/llhttp/http.ts
@@ -582,8 +582,8 @@ export class HTTP {
           span.body.end(n('message_done')))));
 
     n('body_identity_eof')
-      .otherwise(span.body.start(
-        this.update('finish', FINISH.SAFE_WITH_CB, 'eof')));
+      .otherwise(
+        this.update('finish', FINISH.SAFE_WITH_CB, span.body.start(n('eof'))));
 
     // Just read everything until EOF
     n('eof')
@@ -671,8 +671,9 @@ export class HTTP {
     // Check if we'd like to keep-alive
     if (this.mode === 'strict') {
       n('cleanup')
-        .otherwise(p.invoke(callback.afterMessageComplete, this.mode === 'strict' ?
-          { 1: n('restart') } : {}, n('closed')));
+        .otherwise(p.invoke(callback.afterMessageComplete, {
+          1: n('restart'),
+        }, this.update('finish', FINISH.SAFE, n('closed'))));
     } else {
       n('cleanup')
         .otherwise(p.invoke(callback.afterMessageComplete, n('restart')));
@@ -684,7 +685,7 @@ export class HTTP {
         'Data after `Connection: close`'));
 
     n('restart')
-      .otherwise(n('start'));
+      .otherwise(this.update('finish', FINISH.SAFE, n('start')));
   }
 
   private node<T extends Node>(name: string | T): T {

Writing tests...

indutny added a commit that referenced this issue Jun 9, 2019
Although implemented in a compatible way `llhttp_finish()` was never
properly tested until now. Unsurprisingly, there was an incorrect
behavior hidden in there.

Fix: #25
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 a pull request may close this issue.

2 participants