-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Mark,

On 1/12/18 3:27 AM, Mark Thomas wrote:
> On 11/01/18 23:12, Christopher Schultz wrote:
> 
> <snip/>
> 
>> If performance is a consideration, then most of the calls to
>> write() should probably be calls to headerBuffer.put() because we
>> can be (reasonably?) sure that writing "HTTP/1.1 " to the output
>> buffer isn't going to overflow the buffer. Likewise with the
>> bytes for the status code. With an omitted reason phrase, even
>> the trailing SP CR LF can be collapsed into a single byte[] and
>> written a single time to the ByteBuffer, instead of individually
>> as the current code does.
>> 
>> If there is a reason to be inconsistent, let's state it and be 
>> consistently inconsistent. If there is no such reason, let's be 
>> consistent and either always call write() or always call 
>> headerBuffer.put().
>> 
>> Thoughts?
> 
> The length check in write includes an allowance for an additional
> 4 bytes. See BZ 57509 for background.
> 
> I agree that the additional checks (via write()) in sendStatus()
> are unnecessary. If a user sets maxHttpHeaderSize so low you can't
> write the status line then a BufferOverflowException seems
> perfectly reasonable.
> 
> I'm in favour of switching sendStatus() to use headerBuffer.put() 
> throughout, along with adding a comment to the effect that the
> buffer is reset for each request so, unless maxHttpHeaderSize is
> set so low nothing works, the status line will always fit so write
> it directly without length checks.

What do you think about a try/catch for BufferOverflowException that
re-throws the exception as HeadersTooLargeException? Would that
try/catch negatively impact performance enough to earn a -1 ? Since it
would be a hit exactly once per response (right?) it shouldn't be a
big deal, especially when offset by the savings of not re-checking the
buffer many times over (which is my proposal, here, of course).

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQJRBAEBCAA7FiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlpZIXEdHGNocmlzQGNo
cmlzdG9waGVyc2NodWx0ei5uZXQACgkQHPApP6U8pFjbNg/8D8B5a26OIYQCtjUk
AhABuPWPXZmtCVyVIGtmi5r5bnHUZTj84KuxVGmIYLO2sGRaFnSfnCHRySaUwp1r
EEeB0DPAt1vE+TIPRyWJ/XqXFpCjBNid5bD0r09eAWgFR+kos1+wupiIE/91+Xwj
hsrC+pqi9Hst8dieEtKuwiakDYFjyQ8OqTv6ZQ3xce2bQr0Ua8H7RYh5lXkIDVIV
ChRcYTvC76twtTVXl0qvqEwe7UH7N4Y+ae73NTNvbCsUuq99iCr8YM3Hq4CqHnij
k8QTfSOaJ4wkvvnE6pac7pZcyPzA6eB8F1T8VapwqZB82bS3498bI1N4NJ7uLdH5
+6Ub6lWtwUvmpIFbiF/IBAliRked2xDC5lLmvp7ECzux3ytbLZs3wlKJKEr4IMvM
L25qHY3scjgS5fbmmTRu1wZR1NNQGDd2hUMOtIJMdgxqTW/kla+rYBnl0NS9qmRK
/zcWmOhXg5XpWaSYeTzXm5Gah7rezNHHTEy3AovXZ7rw1vvp9c5mcOrPv7rUrJP1
f3iEqUoY57dPdJmwcKx6hZTT7Pf6WZ13wAU3YNp+YEwci8hruRncYEHln06UIY7v
PdB7lq8tQjTOyr1b+ozDWGLuXKxiVLdHKk04H6TmZBr1pd7ldZxuj4RoW3gmtLqD
gwanLMxfx8mY0i23ghlJ0q5tDEs=
=K3Qq
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to