-
Notifications
You must be signed in to change notification settings - Fork 381
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
Addition of Http Parser #3103
Addition of Http Parser #3103
Conversation
Includes some code clean up to fix up warnings (mainly around nullable annotations). Also moves reference parser implementation into a sub-folder.
Add support for parsing leading trivia.
The additions in this file make it possible to put in just a url as a valid request node
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/LexerTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequestParser/HttpRequestParser.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequestParser/HttpRequestParser.cs
Outdated
Show resolved
Hide resolved
...t.DotNet.Interactive.HttpRequest.Tests/Microsoft.DotNet.Interactive.HttpRequest.Tests.csproj
Outdated
Show resolved
Hide resolved
...t.DotNet.Interactive.HttpRequest.Tests/Microsoft.DotNet.Interactive.HttpRequest.Tests.csproj
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequestParser/Reference/DynamicVariable.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest/Microsoft.DotNet.Interactive.HttpRequest.csproj
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequestParser/HttpTokenKind.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequestParser/HttpLexer.cs
Outdated
Show resolved
Hide resolved
Also the addition of a lexer test
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequestParser/HttpSyntaxNodeOrToken.cs
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequestParser/HttpRequestParser.cs
Outdated
Show resolved
Hide resolved
{ | ||
[Fact] | ||
|
||
public void multiple_whitespaces_are_treated_as_a_single_token() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add similar tokenization tests for the other token kinds listed in the TODO comment above.
For example, punctuation should always be split into separate tokens, newline chars should always be split into separate tokens (except when it is \r
followed by \n
), and words should always be combined into a single token.
The tokenization test for newlines would also address Jon's comment above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the tests for whitespace, newline and punctuation are now in place. It would be great to add one for "words should always be combined into a single token" so that we round out all the kinds of tokens that the lexer produces.
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequest.Tests/ParserTests.cs
Outdated
Show resolved
Hide resolved
Content-Type:application/json | ||
#comment | ||
Accept: gzip | ||
"""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should work now, should it not? The comment will be added as leading trivia for the header.
} | ||
|
||
[Fact] | ||
public async Task BodyAfterCommentAsync() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should work now, should it not? The comment should be added as leading trivia for the body.
src/Microsoft.DotNet.Interactive.HttpRequestParser/HttpLexer.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequestParser/HttpLexer.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Interactive.HttpRequestParser/HttpRequestParser.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo comments 👍🏾
Merging |
This is the beginning of a package to tokenize and parse htttp requests.