public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Max Carrara <m.carrara@proxmox.com>
To: Thomas Lamprecht <t.lamprecht@proxmox.com>,
	Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH http-server 0/2] refactor HTTP request processing
Date: Mon, 20 Feb 2023 10:40:29 +0100	[thread overview]
Message-ID: <4472e05c-bac9-17bc-6972-a8788bbef119@proxmox.com> (raw)
In-Reply-To: <b98ed9b8-3417-4a7c-1ad3-6acf6243723e@proxmox.com>

On 2/17/23 18:15, Thomas Lamprecht wrote:
> Am 17/02/2023 um 16:25 schrieb Max Carrara:
>> This patch series refactors the request processing algorithm by
>> separating its data and logic from one another in order to make future
>> changes regarding requests more transparent and explicit.
>>
>> Patch 1: Introduce the refactored algorithm
>> Patch 2: Replace and remove the existing algorithm with the new one
> 
> See not much benefit in having this split into two patches in this way,
> constructing (one or ideally more) patches such that the refactored (out)
> code is directly put to use in(stead of) it's old place has normally more
> benefits, even if just allows one to see what actually moved (e.g., using
> the `--color-moved=zebra --color-moved-ws=ignore-all-space` git switches)
> 
> But no need to resend now, I can squash locally for doing a more in-depth
> review first.

Alright, noted! Will keep that in mind.


>> This refactor is conducted very carefully to ensure that none of the
>> existing behaviours change in any way.
> 
> Careful as in? ^^ Doesn't seem to be a very conservative "just split up",
> but more involved; and there isn't any testing added to ensure the changes
> don't mess with semantics - which tbf might not be the easiest thing to do
> in a sensible manner, that is actually covering a lot, here.
> 
> But especially header parsing with some edge cases could be quite nicely
> done with the respective request methods mocked.

Mocking in which way exactly? Via `curl` or similar, or via separate
tests? If I should add (Perl) tests, where should I put them and how
are they best implemented?


>> One exception however would be
>> the reading of the HTTP header itself: Instead of reading the
>> header by recursively appending / prepending callbacks to the handle's
>> and reading the header line-by-line, the entire header is read at
>> once, reducing the number of callbacks needed to parse the header from
>> the number of lines to one. This affects when the header line count
>> and size limits are checked - instead of being checked *while* the
>> header is being read, these limits are verified *after* the header
>> was read from the read buffer. If this change in behaviour is
>> undesirable, I'll gladly provide a v2.
> 
> that seems to make those limits mostly (i.e., besides maybe proxied
> requests) irrelevant though? If one spent all of the resources to process
> a huge header fully it doesn't makes sense to only then die if it's deemed
> to big.
> 
> But again, I'd wait out for a more in-depth review before going on a v2.

Very fair point - I hadn't viewed it as too problematic in this case,
because HTTP headers rarely get that big anyway, don't they?

>> Otherwise, the behaviour is identical; the logic is restructured,
>> but entirely preserved.
>>
>>
>> To give a more concrete example of what these changes would make more
>> transparent, the enhancement requested in #4494[1] would become just
>> another step (-> subroutine) in the refactored algorithm. That way it
>> becomes much clearer where the TLS handshake is being verified
>> and which responses (e.g. a `301`) are sent in case the handshake
>> never happened or was aborted.
> 
> A patch, even if just POC, would be a more concrete example ;-) that could
> then _actually_ show that the changes actually provide a nicer interface to
> extend.

Sure! I'll send one in.






  reply	other threads:[~2023-02-20  9:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-17 15:25 Max Carrara
2023-02-17 15:25 ` [pve-devel] [PATCH http-server 1/2] http-server: anyevent: add new subroutine for processing requests Max Carrara
2023-02-28 14:05   ` Fabian Grünbichler
2023-02-17 15:25 ` [pve-devel] [PATCH http-server 2/2] http-server: anyevent: replace request processing subroutine Max Carrara
2023-02-17 17:15 ` [pve-devel] [PATCH http-server 0/2] refactor HTTP request processing Thomas Lamprecht
2023-02-20  9:40   ` Max Carrara [this message]
2023-02-20  9:59     ` [pve-devel] [PATCH] http-server: redirect HTTP to HTTPS Max Carrara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4472e05c-bac9-17bc-6972-a8788bbef119@proxmox.com \
    --to=m.carrara@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=t.lamprecht@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal