List of usage examples for org.apache.http.nio NHttpConnection getHttpRequest
HttpRequest getHttpRequest();
From source file:org.apache.synapse.transport.passthru.SourceContext.java
public static void updateState(NHttpConnection conn, ProtocolState state) { SourceContext sourceContext = (SourceContext) conn.getContext().getAttribute(CONNECTION_INFORMATION); if (sourceContext != null) { if (sourceContext.getSourceConfiguration().isCorrelationLoggingEnabled()) { long lastStateUpdateTime = sourceContext.getLastStateUpdatedTime(); String url = "", method = ""; if (sourceContext.getRequest() != null) { url = sourceContext.getRequest().getUri(); method = sourceContext.getRequest().getMethod(); } else { HttpRequest httpRequest = conn.getHttpRequest(); if (httpRequest != null) { url = httpRequest.getRequestLine().getUri(); method = httpRequest.getRequestLine().getMethod(); }/*from w w w. j a va 2 s.c o m*/ } if ((method.length() != 0) && (url.length() != 0)) { MDC.put(PassThroughConstants.CORRELATION_MDC_PROPERTY, conn.getContext().getAttribute(PassThroughConstants.CORRELATION_ID).toString()); correlationLog.info((sourceContext.updateLastStateUpdatedTime() - lastStateUpdateTime) + "|HTTP State Transition|" + conn.getContext().getAttribute("http.connection") + "|" + method + "|" + url + "|" + state.name()); MDC.remove(PassThroughConstants.CORRELATION_MDC_PROPERTY); } } sourceContext.setState(state); } else { throw new IllegalStateException("Connection information should be present"); } }
From source file:org.apache.synapse.transport.passthru.TargetContext.java
public static void updateState(NHttpConnection conn, ProtocolState state) { TargetContext targetContext = (TargetContext) conn.getContext().getAttribute(CONNECTION_INFORMATION); if (targetContext != null) { targetContext.setState(state);/*from w w w. jav a 2 s . c om*/ if (targetContext.getTargetConfiguration().isCorrelationLoggingEnabled() && conn.getContext().getAttribute(PassThroughConstants.CORRELATION_ID) != null) { long lastStateUpdateTime = targetContext.getLastStateUpdatedTime(); String url = "", method = ""; if (targetContext.getRequest() != null) { url = targetContext.getRequest().getUrl().toString(); method = targetContext.getRequest().getMethod(); } else { HttpRequest httpRequest = conn.getHttpRequest(); if (httpRequest != null) { url = httpRequest.getRequestLine().getUri(); method = httpRequest.getRequestLine().getMethod(); } } if ((method.length() != 0) && (url.length() != 0)) { MDC.put(PassThroughConstants.CORRELATION_MDC_PROPERTY, conn.getContext().getAttribute(PassThroughConstants.CORRELATION_ID).toString()); correlationLog.info((targetContext.updateLastStateUpdatedTime() - lastStateUpdateTime) + "|HTTP State Transition|" + conn.getContext().getAttribute("http.connection") + "|" + method + "|" + url + "|" + state.name()); MDC.remove(PassThroughConstants.CORRELATION_MDC_PROPERTY); } } } else { throw new IllegalStateException("Connection information should be present"); } }