C# HTTP proxy performance
I don't program in C and I don't know the exact input strings that you're expecting, but I can offer a couple of regex suggestions based on reasonable assumptions.

Your regex:

@"Host: (((?&lt;hostName&gt;.+?):(?&lt;port&gt;\d+?))|(?&lt;hostName&gt;.+?))\s+"


Your pattern looks for a hostname followed by a colon then a port number then whitespace characters OR a hostname followed by whitespace characters.


Since you are not capturing the whitespace and merely using the whitespace as an end point, the pattern can be reconfigured.
Since the colon-port substring is optional, the zero or one quantifier ? can be used to eliminate the redundant named capture group (which was causing trouble at regex101.com).
+? calls for "lazy" matching.  If you want your pattern to execute quickly, rewrite your pattern to use greedy quantifiers.


New pattern:

@"Host: (?&lt;hostName&gt;[^:\s]+)(:(?&lt;port&gt;\d+))?"


Here is a cheap and cheerful demo: https://regex101.com/r/NqSJ8L/1/

Note, my above pattern could be massaged a few different ways.  For instance, you might use ^ and an m pattern modifier to anchor the pattern to the start of the line of text.  Again, I don't program in C, so I don't know if there are incapatabilities with certain pattern entities.

Or instead of a negated character class, you can list the valid character for a hostname:

@"Host: (?&lt;hostName&gt;[\w.-]+)(:(?&lt;port&gt;\d+))?"


P.s. It just occurred to me that my optional pattern will not always deliver a named capture group for the port, so if you don't want to write code to check that the port capture group is generated, here is OhMyGoodness's commented pattern without the trailing whitespace matching.  (?&lt;= ) is a lookbehind. (?: ) is a non-capturing group.

Host: (?&lt;hostName&gt;[\w.-]+):?(?&lt;port&gt;(?:(?&lt;=:)\d+)?)