Search in sources :

Example 1 with HttpHeader

use of spray.http.HttpHeader in project newrelic-java-agent by newrelic.

the class SprayToResponseMarshallingContext method marshalTo.

@Trace(async = true)
public void marshalTo(HttpResponse httpResponse) {
    Transaction transaction = AgentBridge.getAgent().getTransaction(false);
    if (transaction != null) {
        // First, convert to a java collection so we can add our CAT headers
        List<HttpHeader> modifiableHeaders = new ArrayList<>(JavaConversions.asJavaCollection(httpResponse.headers()));
        // Run through CAT related code to set headers
        transaction.setWebResponse(new ResponseWrapper(httpResponse.status(), modifiableHeaders));
        OutboundWrapper outboundWrapper = new OutboundWrapper(modifiableHeaders);
        transaction.getCrossProcessState().processOutboundResponseHeaders(outboundWrapper, getContentLength(outboundWrapper));
        transaction.markFirstByteOfResponse();
        httpResponse = httpResponse.withHeaders(JavaConversions.asScalaBuffer(modifiableHeaders).toList());
    }
    Weaver.callOriginal();
}
Also used : HttpHeader(spray.http.HttpHeader) Transaction(com.newrelic.agent.bridge.Transaction) ArrayList(java.util.ArrayList) ResponseWrapper(com.agent.instrumentation.spray.ResponseWrapper) OutboundWrapper(com.agent.instrumentation.spray.OutboundWrapper) Trace(com.newrelic.api.agent.Trace)

Aggregations

OutboundWrapper (com.agent.instrumentation.spray.OutboundWrapper)1 ResponseWrapper (com.agent.instrumentation.spray.ResponseWrapper)1 Transaction (com.newrelic.agent.bridge.Transaction)1 Trace (com.newrelic.api.agent.Trace)1 ArrayList (java.util.ArrayList)1 HttpHeader (spray.http.HttpHeader)1