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.
https://github.com/eclipse/jetty.project/blob/master/jetty-server/src/main/java/org/eclipse/jetty/server/ConnectorStatistics.java

Also, the Handler / HandlerWrapper expose the raw Request object in its handle() method.
https://github.com/eclipse/jetty.project/blob/master/jetty-server/src/main/java/org/eclipse/jetty/server/Handler.java#L67

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 jamonapi.com 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?

HttpConnection.getCurrentConnection().getRequest();
 HttpConnection.getCurrentConnection().getResponse();
*****

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
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users



Back to the top