com.signalfx.shaded.jetty.client.ResponseNotifier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of signalfx-codahale Show documentation
Show all versions of signalfx-codahale Show documentation
Dropwizard Codahale metrics plugin for signalfx
The newest version!
//
// ========================================================================
// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package com.signalfx.shaded.jetty.client;
import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.List;
import java.util.function.LongConsumer;
import java.util.function.ObjLongConsumer;
import java.util.stream.Collectors;
import com.signalfx.shaded.jetty.client.api.ContentResponse;
import com.signalfx.shaded.jetty.client.api.Request;
import com.signalfx.shaded.jetty.client.api.Response;
import com.signalfx.shaded.jetty.client.api.Result;
import com.signalfx.shaded.jetty.http.HttpField;
import com.signalfx.shaded.jetty.util.Callback;
import com.signalfx.shaded.jetty.util.CountingCallback;
import com.signalfx.shaded.jetty.util.log.Log;
import com.signalfx.shaded.jetty.util.log.Logger;
public class ResponseNotifier
{
private static final Logger LOG = Log.getLogger(ResponseNotifier.class);
public void notifyBegin(List listeners, Response response)
{
for (Response.ResponseListener listener : listeners)
{
if (listener instanceof Response.BeginListener)
notifyBegin((Response.BeginListener)listener, response);
}
}
private void notifyBegin(Response.BeginListener listener, Response response)
{
try
{
listener.onBegin(response);
}
catch (Throwable x)
{
LOG.info("Exception while notifying listener " + listener, x);
}
}
public boolean notifyHeader(List listeners, Response response, HttpField field)
{
boolean result = true;
for (Response.ResponseListener listener : listeners)
{
if (listener instanceof Response.HeaderListener)
result &= notifyHeader((Response.HeaderListener)listener, response, field);
}
return result;
}
private boolean notifyHeader(Response.HeaderListener listener, Response response, HttpField field)
{
try
{
return listener.onHeader(response, field);
}
catch (Throwable x)
{
LOG.info("Exception while notifying listener " + listener, x);
return false;
}
}
public void notifyHeaders(List listeners, Response response)
{
for (Response.ResponseListener listener : listeners)
{
if (listener instanceof Response.HeadersListener)
notifyHeaders((Response.HeadersListener)listener, response);
}
}
private void notifyHeaders(Response.HeadersListener listener, Response response)
{
try
{
listener.onHeaders(response);
}
catch (Throwable x)
{
LOG.info("Exception while notifying listener " + listener, x);
}
}
public void notifyBeforeContent(Response response, ObjLongConsumer
© 2015 - 2024 Weber Informatics LLC | Privacy Policy