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

[http] Accept headers whether or not preceded by request or response line. #1729

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

garethsb
Copy link

Resolves #1704

@garethsb garethsb changed the title Accept headers whether or not preceded by request or response line. 'http] Accept headers whether or not preceded by request or response line. Aug 13, 2021
@garethsb garethsb changed the title 'http] Accept headers whether or not preceded by request or response line. [http] Accept headers whether or not preceded by request or response line. Aug 13, 2021
@tancnle tancnle added the needs-review The PR needs to be reviewed label Jul 10, 2022
Copy link
Collaborator

@tancnle tancnle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution @garethsb ❤️ Welcome to Rouge. I have added a suggestion for your consideration. Please let me know what you think?

Comment on lines +35 to +36
([^ ]+)(?:([ ]+) # path
(HTTPS?)(/)(\d(?:\.\d)?))?(\r?\n|$) # http version
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Spreading the regex across the two components make it a bit harder to read. Would it be possible to leave it as it is and remove the push :headers statement in both the request and response block?

What do you think about the following diff on master?

diff --git lib/rouge/lexers/http.rb lib/rouge/lexers/http.rb
index 8e4b0fbf..b28124a2 100644
--- lib/rouge/lexers/http.rb
+++ lib/rouge/lexers/http.rb
@@ -40,8 +40,6 @@ module Rouge
             Name::Namespace, Text,
             Keyword, Operator, Num, Text
           )
-
-          push :headers
         end
 
         # response
@@ -55,8 +53,9 @@ module Rouge
             Num, Text,
             Name::Exception, Text
           )
-          push :headers
         end
+
+        mixin :headers
       end
 
       state :headers do

@tancnle tancnle added the author-action The PR has been reviewed but action by the author is needed label Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author-action The PR has been reviewed but action by the author is needed needs-review The PR needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

http lexer should handle blocks of HTTP headers
2 participants