Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Jetty Handlers

With Jetty 9.x

We have our own connector statistics mechanism btw.

Also, the Handler / HandlerWrapper expose the raw Request object in its handle() method.

While there are ways to obtain the raw jetty Request/Response objects, we would encourage you accessing them via the servlet api equivalents instead .. aka HttpServletRequest and HttpServletResponse.

But, that being said, you could access them via ...

HttpConnection.getCurrentConnection().getHttpChannel().getRequest() and .getResponse()

Warning: this API is subject to change for our HTTP/2 efforts (where a single physical connection can have multiple streams, with each one having their own Request and Response objects).  That's the default/standard HTTP/2 behavior (aka a muxed connection).
You'll want to track the HTTP/2 efforts. pay attention to continuation requests (still being debated in the spec group, but it would be a single request being across multiple requests that is eventually combined and then responded to), and any HTTP/2 push concepts where 1 request can result in multiple responses.

Some red flags:
Jetty 7.x+ is highly async, and I see no efforts to understand or handle async request processing in your code.  (This means all of your timing results are going to be misleading)
There's no work in your handler for http upgrade / websocket requests.

Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts

On Tue, Jun 24, 2014 at 11:15 AM, Steve Souza <jamonapi@xxxxxxxxx> wrote:
I am the creator of which is an open source java monitoring tool.  In Jetty 6.15 I provided a jetty Handler that allowed users to easily track page performance, exceptions, bytes sent, http status codes and more.   It doesn't work in later versions of jetty.

Here is the code for the JAMonJettyHandler

The response and Request used to be able to be retrieved with the following methods.  How is that done in more current versions of Jetty?


final Request baseRequest = (request instanceof Request) ? ((Request)request) : HttpConnection.getCurrentConnection().getRequest();

final Response baseResponse = (response instanceof Response) ? ((Response)response) : HttpConnection.getCurrentConnection().getResponse();

jetty-users mailing list

Back to the top