Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Using setDelayDispatchUntilContent

Hi,

On Mon, Dec 11, 2017 at 1:54 AM, Martin Grajcar <maaartinus@xxxxxxxxx> wrote:
> I'm not sure about the exact meaning of setDelayDispatchUntilContent. It's
> documented with
> Whether to delay the application dispatch until content is available
> which may mean it waits until all or some content is available.
> I guess, it means the former, as with many requests, nearly nothing can be
> done, until they're fully available. Am I right?

No, it means to wait to call the application until the first chunk of
content, if any, is available.
This is done because typically the first thing that applications do is
to read the content, and there would be no point in calling the
application to have it block because there is no content available
yet.

> Anyway, is it possible to obtain the time when the request started? I'd need
> it for my statistics.

Yes. If you only need the request start time you can call
Request.getTimeStamp().
Otherwise I suggest you use the more generic HttpChannel.Listener mechanism:

ServerConnector connector = ...;
connector.addBean(new HttpChannel.Listener() {
  @Override
  public void onRequestBegin(Request request) {
    ...
  }
});

which exposes many more events.

> Is there a corresponding option for the output? Some users are on a slow
> connection and then sending a few bytes takes a long time and keeps a thread
> busy.
> At least, that's what I see in my logs: In one case, writing a 200 kB byte
> array to response.getOutputStream() took 20 seconds.

See HttpChannel.Listener above.

Note that all of the above only works for embedded Jetty usage, since
you cannot access server classes from within a deployed web
application.

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


Back to the top