Skip to content

Commit

Permalink
Move UrlConnection wrappers to internal package
Browse files Browse the repository at this point in the history
  • Loading branch information
bidetofevil committed Oct 26, 2023
1 parent 417d2d4 commit ccef18c
Show file tree
Hide file tree
Showing 37 changed files with 239 additions and 228 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.embrace.android.embracesdk.Embrace;
import io.embrace.android.embracesdk.InternalApi;
import io.embrace.android.embracesdk.network.EmbraceNetworkRequest;
import io.embrace.android.embracesdk.network.http.EmbraceHttpPathOverride;
import io.embrace.android.embracesdk.internal.network.http.EmbraceHttpPathOverride;
import io.embrace.android.embracesdk.network.http.HttpMethod;
import okhttp3.Interceptor;
import okhttp3.Request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import io.embrace.android.embracesdk.internal.ApkToolsConfig;
import io.embrace.android.embracesdk.internal.clock.Clock;
import io.embrace.android.embracesdk.network.EmbraceNetworkRequest;
import io.embrace.android.embracesdk.network.http.EmbraceHttpPathOverride;
import io.embrace.android.embracesdk.internal.network.http.EmbraceHttpPathOverride;
import io.embrace.android.embracesdk.network.http.HttpMethod;
import io.embrace.android.embracesdk.network.http.NetworkCaptureData;
import io.embrace.android.embracesdk.internal.network.http.NetworkCaptureData;
import okhttp3.Headers;
import okhttp3.Interceptor;
import okhttp3.Request;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.embrace.android.embracesdk.okhttp3;

import io.embrace.android.embracesdk.HttpPathOverrideRequest;
import io.embrace.android.embracesdk.internal.network.http.HttpPathOverrideRequest;
import okhttp3.Request;

class EmbraceOkHttp3PathOverrideRequest implements HttpPathOverrideRequest {
Expand All @@ -17,7 +17,7 @@ public String getHeaderByName(String name) {
}

@Override
public String getOverriddenURL(String pathOverride) {
public String getOverriddenURL( String pathOverride) {
return request.url().newBuilder().encodedPath(pathOverride).build().toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package io.embrace.android.embracesdk.okhttp3
import io.embrace.android.embracesdk.Embrace
import io.embrace.android.embracesdk.internal.EmbraceInternalInterface
import io.embrace.android.embracesdk.internal.clock.Clock
import io.embrace.android.embracesdk.internal.network.http.NetworkCaptureData
import io.embrace.android.embracesdk.network.EmbraceNetworkRequest
import io.embrace.android.embracesdk.network.http.NetworkCaptureData
import io.embrace.android.embracesdk.okhttp3.EmbraceOkHttp3ApplicationInterceptor.UNKNOWN_EXCEPTION
import io.embrace.android.embracesdk.okhttp3.EmbraceOkHttp3ApplicationInterceptor.UNKNOWN_MESSAGE
import io.embrace.android.embracesdk.okhttp3.EmbraceOkHttp3NetworkInterceptor.CONTENT_ENCODING_HEADER_NAME
Expand Down
90 changes: 45 additions & 45 deletions embrace-android-sdk/api/embrace-android-sdk.api
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,6 @@ public final class io/embrace/android/embracesdk/EmbraceSamples {
public static final fun verifyIntegration ()V
}

public abstract interface class io/embrace/android/embracesdk/HttpPathOverrideRequest {
public abstract fun getHeaderByName (Ljava/lang/String;)Ljava/lang/String;
public abstract fun getOverriddenURL (Ljava/lang/String;)Ljava/lang/String;
public abstract fun getURLString ()Ljava/lang/String;
}

public abstract interface annotation class io/embrace/android/embracesdk/InternalApi : java/lang/annotation/Annotation {
}

Expand Down Expand Up @@ -186,9 +180,9 @@ public abstract interface class io/embrace/android/embracesdk/internal/EmbraceIn
public abstract fun logInfo (Ljava/lang/String;Ljava/util/Map;)V
public abstract fun logWarning (Ljava/lang/String;Ljava/util/Map;Ljava/lang/String;)V
public abstract fun recordAndDeduplicateNetworkRequest (Ljava/lang/String;Lio/embrace/android/embracesdk/network/EmbraceNetworkRequest;)V
public abstract fun recordCompletedNetworkRequest (Ljava/lang/String;Ljava/lang/String;JJJJILjava/lang/String;Lio/embrace/android/embracesdk/network/http/NetworkCaptureData;)V
public abstract fun recordIncompleteNetworkRequest (Ljava/lang/String;Ljava/lang/String;JJLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/NetworkCaptureData;)V
public abstract fun recordIncompleteNetworkRequest (Ljava/lang/String;Ljava/lang/String;JJLjava/lang/Throwable;Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/NetworkCaptureData;)V
public abstract fun recordCompletedNetworkRequest (Ljava/lang/String;Ljava/lang/String;JJJJILjava/lang/String;Lio/embrace/android/embracesdk/internal/network/http/NetworkCaptureData;)V
public abstract fun recordIncompleteNetworkRequest (Ljava/lang/String;Ljava/lang/String;JJLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/embrace/android/embracesdk/internal/network/http/NetworkCaptureData;)V
public abstract fun recordIncompleteNetworkRequest (Ljava/lang/String;Ljava/lang/String;JJLjava/lang/Throwable;Ljava/lang/String;Lio/embrace/android/embracesdk/internal/network/http/NetworkCaptureData;)V
public abstract fun setProcessStartedByNotification ()V
public abstract fun shouldCaptureNetworkBody (Ljava/lang/String;Ljava/lang/String;)Z
}
Expand All @@ -197,15 +191,52 @@ public abstract interface class io/embrace/android/embracesdk/internal/clock/Clo
public abstract fun now ()J
}

public class io/embrace/android/embracesdk/internal/network/http/EmbraceHttpPathOverride {
protected static final field PATH_OVERRIDE Ljava/lang/String;
public fun <init> ()V
public static fun getURLString (Lio/embrace/android/embracesdk/internal/network/http/HttpPathOverrideRequest;)Ljava/lang/String;
public static fun getURLString (Lio/embrace/android/embracesdk/internal/network/http/HttpPathOverrideRequest;Ljava/lang/String;)Ljava/lang/String;
}

public abstract interface class io/embrace/android/embracesdk/internal/network/http/HttpPathOverrideRequest {
public abstract fun getHeaderByName (Ljava/lang/String;)Ljava/lang/String;
public abstract fun getOverriddenURL (Ljava/lang/String;)Ljava/lang/String;
public abstract fun getURLString ()Ljava/lang/String;
}

public final class io/embrace/android/embracesdk/internal/network/http/NetworkCaptureData {
public fun <init> (Ljava/util/Map;Ljava/lang/String;[BLjava/util/Map;[BLjava/lang/String;)V
public synthetic fun <init> (Ljava/util/Map;Ljava/lang/String;[BLjava/util/Map;[BLjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ljava/util/Map;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()[B
public final fun component4 ()Ljava/util/Map;
public final fun component5 ()[B
public final fun component6 ()Ljava/lang/String;
public final fun copy (Ljava/util/Map;Ljava/lang/String;[BLjava/util/Map;[BLjava/lang/String;)Lio/embrace/android/embracesdk/internal/network/http/NetworkCaptureData;
public static synthetic fun copy$default (Lio/embrace/android/embracesdk/internal/network/http/NetworkCaptureData;Ljava/util/Map;Ljava/lang/String;[BLjava/util/Map;[BLjava/lang/String;ILjava/lang/Object;)Lio/embrace/android/embracesdk/internal/network/http/NetworkCaptureData;
public fun equals (Ljava/lang/Object;)Z
public final fun getCapturedRequestBody ()[B
public final fun getCapturedResponseBody ()[B
public final fun getDataCaptureErrorMessage ()Ljava/lang/String;
public final fun getRequestBodySize ()I
public final fun getRequestHeaders ()Ljava/util/Map;
public final fun getRequestQueryParams ()Ljava/lang/String;
public final fun getResponseBodySize ()I
public final fun getResponseHeaders ()Ljava/util/Map;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class io/embrace/android/embracesdk/network/EmbraceNetworkRequest {
public static fun fromCompletedRequest (Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/HttpMethod;JJJJI)Lio/embrace/android/embracesdk/network/EmbraceNetworkRequest;
public static fun fromCompletedRequest (Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/HttpMethod;JJJJILjava/lang/String;)Lio/embrace/android/embracesdk/network/EmbraceNetworkRequest;
public static fun fromCompletedRequest (Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/HttpMethod;JJJJILjava/lang/String;Lio/embrace/android/embracesdk/network/http/NetworkCaptureData;)Lio/embrace/android/embracesdk/network/EmbraceNetworkRequest;
public static fun fromCompletedRequest (Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/HttpMethod;JJJJILjava/lang/String;Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/NetworkCaptureData;)Lio/embrace/android/embracesdk/network/EmbraceNetworkRequest;
public static fun fromCompletedRequest (Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/HttpMethod;JJJJILjava/lang/String;Lio/embrace/android/embracesdk/internal/network/http/NetworkCaptureData;)Lio/embrace/android/embracesdk/network/EmbraceNetworkRequest;
public static fun fromCompletedRequest (Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/HttpMethod;JJJJILjava/lang/String;Ljava/lang/String;Lio/embrace/android/embracesdk/internal/network/http/NetworkCaptureData;)Lio/embrace/android/embracesdk/network/EmbraceNetworkRequest;
public static fun fromIncompleteRequest (Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/HttpMethod;JJLjava/lang/String;Ljava/lang/String;)Lio/embrace/android/embracesdk/network/EmbraceNetworkRequest;
public static fun fromIncompleteRequest (Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/HttpMethod;JJLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/embrace/android/embracesdk/network/EmbraceNetworkRequest;
public static fun fromIncompleteRequest (Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/HttpMethod;JJLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/NetworkCaptureData;)Lio/embrace/android/embracesdk/network/EmbraceNetworkRequest;
public static fun fromIncompleteRequest (Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/HttpMethod;JJLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/NetworkCaptureData;)Lio/embrace/android/embracesdk/network/EmbraceNetworkRequest;
public static fun fromIncompleteRequest (Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/HttpMethod;JJLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/embrace/android/embracesdk/internal/network/http/NetworkCaptureData;)Lio/embrace/android/embracesdk/network/EmbraceNetworkRequest;
public static fun fromIncompleteRequest (Ljava/lang/String;Lio/embrace/android/embracesdk/network/http/HttpMethod;JJLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/embrace/android/embracesdk/internal/network/http/NetworkCaptureData;)Lio/embrace/android/embracesdk/network/EmbraceNetworkRequest;
public fun getBytesIn ()Ljava/lang/Long;
public fun getBytesOut ()Ljava/lang/Long;
public fun getBytesReceived ()Ljava/lang/Long;
Expand All @@ -215,21 +246,14 @@ public final class io/embrace/android/embracesdk/network/EmbraceNetworkRequest {
public fun getErrorMessage ()Ljava/lang/String;
public fun getErrorType ()Ljava/lang/String;
public fun getHttpMethod ()Ljava/lang/String;
public fun getNetworkCaptureData ()Lio/embrace/android/embracesdk/network/http/NetworkCaptureData;
public fun getNetworkCaptureData ()Lio/embrace/android/embracesdk/internal/network/http/NetworkCaptureData;
public fun getResponseCode ()Ljava/lang/Integer;
public fun getStartTime ()Ljava/lang/Long;
public fun getTraceId ()Ljava/lang/String;
public fun getUrl ()Ljava/lang/String;
public fun getW3cTraceparent ()Ljava/lang/String;
}

public class io/embrace/android/embracesdk/network/http/EmbraceHttpPathOverride {
protected static final field PATH_OVERRIDE Ljava/lang/String;
public fun <init> ()V
public static fun getURLString (Lio/embrace/android/embracesdk/HttpPathOverrideRequest;)Ljava/lang/String;
public static fun getURLString (Lio/embrace/android/embracesdk/HttpPathOverrideRequest;Ljava/lang/String;)Ljava/lang/String;
}

public final class io/embrace/android/embracesdk/network/http/HttpMethod : java/lang/Enum {
public static final field CONNECT Lio/embrace/android/embracesdk/network/http/HttpMethod;
public static final field DELETE Lio/embrace/android/embracesdk/network/http/HttpMethod;
Expand All @@ -246,30 +270,6 @@ public final class io/embrace/android/embracesdk/network/http/HttpMethod : java/
public static fun values ()[Lio/embrace/android/embracesdk/network/http/HttpMethod;
}

public final class io/embrace/android/embracesdk/network/http/NetworkCaptureData {
public fun <init> (Ljava/util/Map;Ljava/lang/String;[BLjava/util/Map;[BLjava/lang/String;)V
public synthetic fun <init> (Ljava/util/Map;Ljava/lang/String;[BLjava/util/Map;[BLjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ljava/util/Map;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()[B
public final fun component4 ()Ljava/util/Map;
public final fun component5 ()[B
public final fun component6 ()Ljava/lang/String;
public final fun copy (Ljava/util/Map;Ljava/lang/String;[BLjava/util/Map;[BLjava/lang/String;)Lio/embrace/android/embracesdk/network/http/NetworkCaptureData;
public static synthetic fun copy$default (Lio/embrace/android/embracesdk/network/http/NetworkCaptureData;Ljava/util/Map;Ljava/lang/String;[BLjava/util/Map;[BLjava/lang/String;ILjava/lang/Object;)Lio/embrace/android/embracesdk/network/http/NetworkCaptureData;
public fun equals (Ljava/lang/Object;)Z
public final fun getCapturedRequestBody ()[B
public final fun getCapturedResponseBody ()[B
public final fun getDataCaptureErrorMessage ()Ljava/lang/String;
public final fun getRequestBodySize ()I
public final fun getRequestHeaders ()Ljava/util/Map;
public final fun getRequestQueryParams ()Ljava/lang/String;
public final fun getResponseBodySize ()I
public final fun getResponseHeaders ()Ljava/util/Map;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public abstract interface class io/embrace/android/embracesdk/spans/EmbraceSpan {
public abstract fun addAttribute (Ljava/lang/String;Ljava/lang/String;)Z
public abstract fun addEvent (Ljava/lang/String;)Z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import io.embrace.android.embracesdk.IntegrationTestRule
import io.embrace.android.embracesdk.network.EmbraceNetworkRequest
import io.embrace.android.embracesdk.network.http.HttpMethod
import io.embrace.android.embracesdk.network.http.NetworkCaptureData
import io.embrace.android.embracesdk.internal.network.http.NetworkCaptureData
import io.embrace.android.embracesdk.payload.NetworkCallV2
import io.embrace.android.embracesdk.recordSession
import org.junit.Assert.assertEquals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
import io.embrace.android.embracesdk.ndk.NativeModuleImpl;
import io.embrace.android.embracesdk.ndk.NdkService;
import io.embrace.android.embracesdk.network.EmbraceNetworkRequest;
import io.embrace.android.embracesdk.network.http.HttpUrlConnectionTracker;
import io.embrace.android.embracesdk.network.http.NetworkCaptureData;
import io.embrace.android.embracesdk.internal.network.http.HttpUrlConnectionTracker;
import io.embrace.android.embracesdk.internal.network.http.NetworkCaptureData;
import io.embrace.android.embracesdk.network.logging.NetworkCaptureService;
import io.embrace.android.embracesdk.network.logging.NetworkLoggingService;
import io.embrace.android.embracesdk.payload.PushNotificationBreadcrumb;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package io.embrace.android.embracesdk
import android.util.Pair
import io.embrace.android.embracesdk.injection.InitModule
import io.embrace.android.embracesdk.internal.EmbraceInternalInterface
import io.embrace.android.embracesdk.internal.network.http.NetworkCaptureData
import io.embrace.android.embracesdk.network.EmbraceNetworkRequest
import io.embrace.android.embracesdk.network.http.HttpMethod
import io.embrace.android.embracesdk.network.http.NetworkCaptureData
import io.embrace.android.embracesdk.payload.TapBreadcrumb

internal class EmbraceInternalInterfaceImpl(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import android.util.Pair
import io.embrace.android.embracesdk.Embrace
import io.embrace.android.embracesdk.InternalApi
import io.embrace.android.embracesdk.LogType
import io.embrace.android.embracesdk.internal.network.http.NetworkCaptureData
import io.embrace.android.embracesdk.network.EmbraceNetworkRequest
import io.embrace.android.embracesdk.network.http.NetworkCaptureData

/**
* Provides an internal interface to Embrace that is intended for use by hosted SDKs as their sole source of communication
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.embrace.android.embracesdk.network.http;
package io.embrace.android.embracesdk.internal.network.http;

import androidx.annotation.NonNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.embrace.android.embracesdk.network.http;
package io.embrace.android.embracesdk.internal.network.http;

import java.io.ByteArrayOutputStream;
import java.io.FilterOutputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.embrace.android.embracesdk.network.http;
package io.embrace.android.embracesdk.internal.network.http;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.regex.Pattern;

import io.embrace.android.embracesdk.HttpPathOverrideRequest;
import io.embrace.android.embracesdk.InternalApi;
import io.embrace.android.embracesdk.logging.InternalStaticEmbraceLogger;

Expand All @@ -28,13 +30,15 @@ public class EmbraceHttpPathOverride {
private static final Pattern RELATIVE_PATH_PATTERN = Pattern.compile("[A-Za-z0-9-._~:/\\[\\]@!$&'()*+,;=]+");

@SuppressWarnings("AbbreviationAsWordInNameCheck")
public static String getURLString(HttpPathOverrideRequest request) {
@NonNull
public static String getURLString(@NonNull HttpPathOverrideRequest request) {
return getURLString(request, request.getHeaderByName(PATH_OVERRIDE));
}

@SuppressWarnings("AbbreviationAsWordInNameCheck")
@InternalApi
public static String getURLString(HttpPathOverrideRequest request, String pathOverride) {
@NonNull
public static String getURLString(@NonNull HttpPathOverrideRequest request, @Nullable String pathOverride) {
String url;
try {
if (pathOverride != null && validatePathOverride(pathOverride)) {
Expand Down Expand Up @@ -65,7 +69,7 @@ private static Boolean validatePathOverride(String path) {
}
if (!StandardCharsets.US_ASCII.newEncoder().canEncode(path)) {
InternalStaticEmbraceLogger.logError("Relative path must not contain unicode " +
"characters. Relative path " + path + " will be ignored.");
"characters. Relative path " + path + " will be ignored.");
return false;
}
if (!path.startsWith("/")) {
Expand All @@ -74,7 +78,7 @@ private static Boolean validatePathOverride(String path) {
}
if (!RELATIVE_PATH_PATTERN.matcher(path).matches()) {
InternalStaticEmbraceLogger.logError("Relative path contains invalid chars. " +
"Relative path " + path + " will be ignored.");
"Relative path " + path + " will be ignored.");
return false;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.embrace.android.embracesdk.network.http;
package io.embrace.android.embracesdk.internal.network.http;

import android.annotation.TargetApi;

Expand Down
Loading

0 comments on commit ccef18c

Please sign in to comment.