use of com.pamirs.pradar.interceptor.ContextTransfer in project LinkAgent by shulieTech.
the class HttpRequestExecuteMethodInterceptor method getContextTransfer.
@Override
protected ContextTransfer getContextTransfer(Advice advice) {
Object target = advice.getTarget();
final HttpRequest request = (HttpRequest) target;
final HttpHeaders headers = request.getHeaders();
return new ContextTransfer() {
@Override
public void transfer(String key, String value) {
headers.set(key, Collections.singletonList(value));
}
};
}
use of com.pamirs.pradar.interceptor.ContextTransfer in project LinkAgent by shulieTech.
the class HttpEncoderInterceptor method getContextTransfer.
@Override
protected ContextTransfer getContextTransfer(Advice advice) {
Object[] args = advice.getParameterArray();
final HttpMessage httpMessage = (HttpMessage) args[1];
Map<String, String> context = manager.getDynamicField(httpMessage, NettyConstants.DYNAMIC_FIELD_ASYNC_CONTEXT);
InvokeContext invokeContext_ = Pradar.fromMap(context);
if (Pradar.hasInvokeContext(context) || Pradar.hasInvokeContext()) {
return new ContextTransfer() {
@Override
public void transfer(String key, String value) {
HttpHeaders headers = httpMessage.headers();
if (headers != null && !headers.contains(key)) {
headers.set(key, value);
}
}
};
}
return null;
}
use of com.pamirs.pradar.interceptor.ContextTransfer in project LinkAgent by shulieTech.
the class HttpClientv3MethodInterceptor method getContextTransfer.
@Override
protected ContextTransfer getContextTransfer(Advice advice) {
Object[] args = advice.getParameterArray();
final HttpMethod method = (HttpMethod) args[1];
if (method == null) {
return null;
}
return new ContextTransfer() {
@Override
public void transfer(String key, String value) {
method.setRequestHeader(key, value);
}
};
}
use of com.pamirs.pradar.interceptor.ContextTransfer in project LinkAgent by shulieTech.
the class HttpClientv5MethodInterceptor method getContextTransfer.
@Override
protected ContextTransfer getContextTransfer(Advice advice) {
Object[] args = advice.getParameterArray();
HttpHost httpHost = (HttpHost) args[0];
final HttpRequest request = (HttpRequest) args[1];
if (httpHost == null) {
return null;
}
return new ContextTransfer() {
@Override
public void transfer(String key, String value) {
if (request.getHeaders(HeaderMark.DONT_MODIFY_HEADER) == null || request.getHeaders(HeaderMark.DONT_MODIFY_HEADER).length == 0) {
request.setHeader(key, value);
}
}
};
}
use of com.pamirs.pradar.interceptor.ContextTransfer in project LinkAgent by shulieTech.
the class HttpURLConnectionInterceptor method getContextTransfer.
@Override
protected ContextTransfer getContextTransfer(Advice advice) {
Object target = advice.getTarget();
final HttpURLConnection request = (HttpURLConnection) target;
boolean connecting = advice.hasMark(MARK_CONNECTING);
boolean connected = advice.hasMark(MARK_CONNECTED);
if (connected || connecting) {
return null;
}
return new ContextTransfer() {
@Override
public void transfer(String key, String value) {
request.setRequestProperty(key, value);
}
};
}
Aggregations