use of com.ning.http.client.FluentCaseInsensitiveStringsMap in project scribejava by scribejava.
the class OAuthAsyncCompletionHandler method onCompleted.
@Override
public T onCompleted(com.ning.http.client.Response ningResponse) throws IOException {
final FluentCaseInsensitiveStringsMap map = ningResponse.getHeaders();
final Map<String, String> headersMap = new HashMap<>();
for (FluentCaseInsensitiveStringsMap.Entry<String, List<String>> header : map) {
final StringBuilder value = new StringBuilder();
for (String str : header.getValue()) {
value.append(str);
}
headersMap.put(header.getKey(), value.toString());
}
final Response response = new Response(ningResponse.getStatusCode(), ningResponse.getStatusText(), headersMap, ningResponse.getResponseBodyAsStream());
@SuppressWarnings("unchecked") final T t = converter == null ? (T) response : converter.convert(response);
if (callback != null) {
callback.onCompleted(t);
}
return t;
}
use of com.ning.http.client.FluentCaseInsensitiveStringsMap in project pinpoint by naver.
the class ExecuteRequestInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
final Trace trace = traceContext.currentRawTraceObject();
if (trace == null) {
return;
}
if (args.length == 0 || !(args[0] instanceof com.ning.http.client.Request)) {
return;
}
final com.ning.http.client.Request httpRequest = (com.ning.http.client.Request) args[0];
final boolean sampling = trace.canSampled();
if (!sampling) {
if (isDebug) {
logger.debug("set Sampling flag=false");
}
if (httpRequest != null) {
final FluentCaseInsensitiveStringsMap httpRequestHeaders = httpRequest.getHeaders();
httpRequestHeaders.add(Header.HTTP_SAMPLED.toString(), SamplingFlagUtils.SAMPLING_RATE_FALSE);
}
return;
}
trace.traceBlockBegin();
SpanEventRecorder recorder = trace.currentSpanEventRecorder();
TraceId nextId = trace.getTraceId().getNextTraceId();
recorder.recordNextSpanId(nextId.getSpanId());
recorder.recordServiceType(NingAsyncHttpClientPlugin.ASYNC_HTTP_CLIENT);
if (httpRequest != null) {
final FluentCaseInsensitiveStringsMap httpRequestHeaders = httpRequest.getHeaders();
putHeader(httpRequestHeaders, Header.HTTP_TRACE_ID.toString(), nextId.getTransactionId());
putHeader(httpRequestHeaders, Header.HTTP_SPAN_ID.toString(), String.valueOf(nextId.getSpanId()));
putHeader(httpRequestHeaders, Header.HTTP_PARENT_SPAN_ID.toString(), String.valueOf(nextId.getParentSpanId()));
putHeader(httpRequestHeaders, Header.HTTP_FLAGS.toString(), String.valueOf(nextId.getFlags()));
putHeader(httpRequestHeaders, Header.HTTP_PARENT_APPLICATION_NAME.toString(), traceContext.getApplicationName());
putHeader(httpRequestHeaders, Header.HTTP_PARENT_APPLICATION_TYPE.toString(), Short.toString(traceContext.getServerTypeCode()));
final String hostString = getEndpoint(httpRequest.getURI().getHost(), httpRequest.getURI().getPort());
if (hostString != null) {
putHeader(httpRequestHeaders, Header.HTTP_HOST.toString(), hostString);
}
}
}
Aggregations