Skip to content

Commit

Permalink
fix add trailers headers
Browse files Browse the repository at this point in the history
  • Loading branch information
kernel0x committed Jan 25, 2024
1 parent a4ab3cb commit cef4579
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ Pick a UI implementation and add the dependency:

````java
dependencies {
debugImplementation 'com.github.kernel0x.finch:ui-drawer:2.2.6'
releaseImplementation 'com.github.kernel0x.finch:noop:2.2.6'
debugImplementation 'com.github.kernel0x.finch:ui-drawer:2.2.7'
releaseImplementation 'com.github.kernel0x.finch:noop:2.2.7'
// optional only for OkHttp
debugImplementation 'com.github.kernel0x.finch:log-okhttp:2.2.6'
releaseImplementation 'com.github.kernel0x.finch:log-okhttp-noop:2.2.6'
debugImplementation 'com.github.kernel0x.finch:log-okhttp:2.2.7'
releaseImplementation 'com.github.kernel0x.finch:log-okhttp-noop:2.2.7'
// optional only for GRPC
debugImplementation 'com.github.kernel0x.finch:log-grpc:2.2.6'
releaseImplementation 'com.github.kernel0x.finch:log-grpc-noop:2.2.6'
debugImplementation 'com.github.kernel0x.finch:log-grpc:2.2.7'
releaseImplementation 'com.github.kernel0x.finch:log-grpc-noop:2.2.7'
// optional only for logs
debugImplementation 'com.github.kernel0x.finch:log:2.2.6'
releaseImplementation 'com.github.kernel0x.finch:log-noop:2.2.6'
debugImplementation 'com.github.kernel0x.finch:log:2.2.7'
releaseImplementation 'com.github.kernel0x.finch:log-noop:2.2.7'
}
````

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.google.gson.reflect.TypeToken
import com.kernel.finch.common.loggers.data.models.NetworkLogEntity.Companion.TABLE_NAME
import com.kernel.finch.common.loggers.utils.FormatUtil
import com.kernel.finch.common.loggers.utils.GsonUtil
import java.util.*
import java.util.Locale

@Suppress("TooManyFunctions")
@Keep
Expand Down Expand Up @@ -73,6 +73,15 @@ data class NetworkLogEntity(
responseHeaders = GsonUtil.instance.toJson(headers)
}

fun addResponseHeaders(headers: List<HeaderHttpModel>) {
setResponseHeaders(
arrayListOf<HeaderHttpModel>().apply {
addAll(getResponseHeadersAsList() ?: emptyList())
addAll(headers)
}
)
}

fun getResponseHeadersAsList(): List<HeaderHttpModel>? {
return GsonUtil.instance.fromJson<List<HeaderHttpModel>>(
responseHeaders,
Expand Down
4 changes: 2 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ ext.versions = [
minSdk : 21,
targetSdk : 34,
compileSdk : 34,
libraryVersion : '2.2.6',
libraryVersionCode: 13,
libraryVersion : '2.2.7',
libraryVersionCode: 14,

okhttp3 : '3.7.0',
gson : '2.8.2',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ internal class FinchClientInterceptor : ClientInterceptor {
if (status.description?.isNotEmpty() == true) {
networkLog.responseMessage += " (" + status.description + ")"
}
networkLog.setResponseHeaders(toHttpHeaderList(trailers))
networkLog.addResponseHeaders(toHttpHeaderList(trailers))
FinchGrpcLogger.logNetworkEvent(networkLog)
super.onClose(status, trailers)
}
Expand Down
12 changes: 6 additions & 6 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ android {
}

dependencies {
//debugImplementation 'com.github.kernel0x.finch:ui-drawer:2.2.6'
//releaseImplementation 'com.github.kernel0x.finch:noop:2.2.6'
//debugImplementation 'com.github.kernel0x.finch:log-okhttp:2.2.6'
//releaseImplementation 'com.github.kernel0x.finch:log-okhttp-noop:2.2.6'
//debugImplementation 'com.github.kernel0x.finch:log:2.2.6'
//releaseImplementation 'com.github.kernel0x.finch:log-noop:2.2.6'
//debugImplementation 'com.github.kernel0x.finch:ui-drawer:2.2.7'
//releaseImplementation 'com.github.kernel0x.finch:noop:2.2.7'
//debugImplementation 'com.github.kernel0x.finch:log-okhttp:2.2.7'
//releaseImplementation 'com.github.kernel0x.finch:log-okhttp-noop:2.2.7'
//debugImplementation 'com.github.kernel0x.finch:log:2.2.7'
//releaseImplementation 'com.github.kernel0x.finch:log-noop:2.2.7'
debugImplementation project(":ui-drawer")
debugImplementation project(":log")
debugImplementation project(":log-okhttp")
Expand Down

0 comments on commit cef4579

Please sign in to comment.