com.eg.agent.android.instrumentation.OkHttp3Instrumentation Maven / Gradle / Ivy
package com.eg.agent.android.instrumentation;
import android.util.Log;
import com.eg.agent.android.instrumentation.NetworkInformation.HttpURLConnectionExtension;
import com.eg.agent.android.instrumentation.NetworkInformation.HttpsURLConnectionExtension;
import com.eg.agent.android.logging.AgentLog;
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import static com.eg.agent.android.logging.AgentLogManager.getAgentLog;
/**
* Created by Venkateswari.J on 10/26/2017.
*/
public class OkHttp3Instrumentation
{
private static final AgentLog log = getAgentLog();
@WrapReturn(className="okhttp3/OkHttpClient", methodName="open", methodDesc="(Ljava/net/URL;)Ljava/net/HttpURLConnection;")
public static HttpURLConnection open(HttpURLConnection connection) {
/* if ((connection instanceof HttpsURLConnection))
return new HttpsURLConnectionExtension((HttpsURLConnection) connection);
if (connection != null) {
return new HttpURLConnectionExtension(connection);
}*/
if ((connection instanceof HttpsURLConnection)) {
return new HttpsURLConnectionExtension((HttpsURLConnection) connection);
}
if (connection!=null) {
Log.e("eGAndroidAgent", "OkHttpCOnnection");
System.out.println("OKHttpConnection");
return new HttpURLConnectionExtension(connection);
}
return null;
}
@WrapReturn(className="okhttp3/OkHttpClient", methodName="open", methodDesc="(Ljava/net/URL;Ljava/net/Proxy)Ljava/net/HttpURLConnection;")
public static HttpURLConnection openWithProxy(HttpURLConnection connection) {
if ((connection instanceof HttpsURLConnection))
return new HttpsURLConnectionExtension((HttpsURLConnection) connection);
if (connection != null) {
return new HttpURLConnectionExtension(connection);
}
return null;
}
@WrapReturn(className="okhttp3/OkUrlFactory", methodName="open", methodDesc="(Ljava/net/URL;)Ljava/net/HttpURLConnection;")
public static HttpURLConnection urlFactoryOpen(HttpURLConnection connection) {
log.debug("OkHttpInstrumentation - wrapping return of call to OkUrlFactory.open...");
if ((connection instanceof HttpsURLConnection))
return new HttpsURLConnectionExtension((HttpsURLConnection) connection);
if (connection != null) {
return new HttpURLConnectionExtension(connection);
}
return null;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy