Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Custom bad message error page

Hi,

On Mon, Aug 7, 2023 at 12:16 PM Silvio Bierman via jetty-users
<jetty-users@xxxxxxxxxxx> wrote:
>
> Hi,
>
> I run embedded Jetty 11.0.13. I have a single servlet instance and call ServletContextHandler#setErrorHandler(customHandler) during initialization. But whenever an invalid URL (like one containing empty segments) the handle method of the custom errorhandler is not called. Instead the message
>
> Bad Message 400
>
> reason: Ambiguous URI empty segment
>
> is generated. Similarly requests with a bad SNI seem to generate a page that does not go through the custom handler.
>
> What am I doing wrong? How can I catch these and generate my own error pages?

Some errors happen very early in the request parsing, so when they
happen, there is no request, no headers, etc. so we cannot dispatch a
"request" to a handler (there is no request).
These are typically requests that are so bad that are typically
attacks, so you don't want to generate more than a concise 400
response from the server, as if the request never arrived.

For the particular error "Ambiguous URI empty segment" you can
configure the HTTP compliance so that the ambiguity is tolerated, and
the request handled as a normal request.
See https://eclipse.dev/jetty/documentation/jetty-11/programming-guide/index.html#pg-server-compliance-http.

-- 
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.


Back to the top