Skip to content

HTTP: Improved field-line parser #2037

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

yadij
Copy link
Contributor

@yadij yadij commented Mar 23, 2025

Replace with a Tokenizer based Parser and
updated for RFC 9110 and RFC 9112 compliance.

yadij added 2 commits March 23, 2025 15:05
Replace with a Tokenizer based Parser and
updated for RFC 9110 and RFC 9112 compliance.
@rousskov rousskov self-requested a review March 23, 2025 14:41
Copy link
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

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

@yadij, before posting new master/v8 PRs, please cooperate on merging PRs (authored by others) that are awaiting your actions for weeks and even months. I have begged you many times already. Since you are not responding to my requests, I will stop making new ones, but the absence of such comments does not indicate that the problem is gone. When/if the problem is actually solved, I will write a dedicated comment.

@rousskov rousskov self-requested a review March 24, 2025 02:07
Copy link
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

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

I will come back to this after the backlog is gone, but I left a few change requests to make progress possible.

{
namespace One
{
class FieldParser : public Http::FieldParser
Copy link
Contributor

Choose a reason for hiding this comment

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

Please do not use inheritance for this API. There are problems with the suggested implementation, and the associated complexity is not needed. Just implement Http::One::FieldParser as a stand-alone class, "inlining" or "merging" Http::FieldParser class into Http::One::FieldParser.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FTR: HTTP/2 addition to Squid is currently blocked on lack of src/http/Parser.h for the generic RFC 9110 parsing requirements currently stuck in src/http/one/Parser.h class with integrated RFC 9112 behaviour being imposed.
This class inheritance is necessary to prevent the same issues being compounded by this HTTP field parser imposing RFC 9112 behaviours on RFC 9113 and 9114 field parsers.

Copy link
Contributor

Choose a reason for hiding this comment

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

The change request stands. The proposed class hierarchy is badly implemented and is currently unnecessary. We will split this class later if necessary.

P.S. HTTP/2 work is blocked for other reasons IMO, but we do not need to agree on that point.


public:
/// parse an HTTP header field from the given tokenizer
void parseFieldLine(::Parser::Tokenizer &, const http_hdr_owner_type);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please convert this method into a class constructor (instead of allowing special FieldParser instances that have not parsed anything at al or half-valid instances that have not finished parsing).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. The requested change would lock this parser to only being capable of parsing HTTP/1.x MiME based message headers. This is an RFC 9112 field-line parser, not a RFC 822 / RFC 2616 header parser.

Copy link
Contributor

Choose a reason for hiding this comment

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

The requested change would lock this parser to only being capable of parsing HTTP/1.x MiME based message headers. This is an RFC 9112 field-line parser, not a RFC 822 / RFC 2616 header parser.

How would converting this method into constructor prevent this class from parsing RFC 9112 field-lines?


if (!tok.atEnd()) {
const auto garbage = tok.remaining();
const auto limit = min(garbage.length(), SBuf::size_type(100));
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this dangerous and duplicated output limiting code to the Raw class itself, adding Raw::upTo(limit) or a similar method (where we can properly report the actual length and properly add ... to the truncated output).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You have asked for this before, then vetoed the PR adding the requested change. Will not repeat here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I assume you are talking about #466. I did not veto that PR. In fact, I explicitly supported it. Once its problems are fixed, it should be merged (and used here).

@yadij yadij requested a review from rousskov April 3, 2025 14:37
{
namespace One
{
class FieldParser : public Http::FieldParser
Copy link
Contributor

Choose a reason for hiding this comment

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

The change request stands. The proposed class hierarchy is badly implemented and is currently unnecessary. We will split this class later if necessary.

P.S. HTTP/2 work is blocked for other reasons IMO, but we do not need to agree on that point.


public:
/// parse an HTTP header field from the given tokenizer
void parseFieldLine(::Parser::Tokenizer &, const http_hdr_owner_type);
Copy link
Contributor

Choose a reason for hiding this comment

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

The requested change would lock this parser to only being capable of parsing HTTP/1.x MiME based message headers. This is an RFC 9112 field-line parser, not a RFC 822 / RFC 2616 header parser.

How would converting this method into constructor prevent this class from parsing RFC 9112 field-lines?


if (!tok.atEnd()) {
const auto garbage = tok.remaining();
const auto limit = min(garbage.length(), SBuf::size_type(100));
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume you are talking about #466. I did not veto that PR. In fact, I explicitly supported it. Once its problems are fixed, it should be merged (and used here).

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.

2 participants