File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
core/network/src/main/kotlin/com/ninecraft/booket/core/network/di Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,20 @@ private val jsonRule = Json {
3333
3434private val jsonConverterFactory = jsonRule.asConverterFactory(" application/json" .toMediaType())
3535
36+ private val FILTERED_HEADERS = setOf (
37+ " transfer-encoding" ,
38+ " connection" ,
39+ " x-content-type-options" ,
40+ " x-xss-protection" ,
41+ " cache-control" ,
42+ " pragma" ,
43+ " expires" ,
44+ " x-frame-options" ,
45+ " keep-alive" ,
46+ " server" ,
47+ " content-length" ,
48+ )
49+
3650@Module
3751@InstallIn(SingletonComponent ::class )
3852internal object NetworkModule {
@@ -56,7 +70,14 @@ internal object NetworkModule {
5670 networkLogAdapter : AndroidLogAdapter ,
5771 ): HttpLoggingInterceptor {
5872 return HttpLoggingInterceptor { message ->
59- if (message.isNotBlank()) {
73+ val shouldFilter = FILTERED_HEADERS .any { header ->
74+ message.lowercase().contains(" $header :" )
75+ }
76+
77+ val isDuplicateContentType = message.lowercase().contains(" content-type: application/json" ) &&
78+ ! message.contains(" charset" )
79+
80+ if (! shouldFilter && ! isDuplicateContentType && message.isNotBlank()) {
6081 networkLogAdapter.log(Log .DEBUG , null , message)
6182 }
6283 }.apply {
You can’t perform that action at this time.
0 commit comments