Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
4dfc6b87
Commit
4dfc6b87
authored
Aug 02, 2022
by
万齐军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network_api事件上报
parent
f1a202ec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
9 deletions
+14
-9
HttpConfig.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/HttpConfig.kt
+14
-9
No files found.
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/HttpConfig.kt
View file @
4dfc6b87
...
@@ -35,8 +35,6 @@ import okio.BufferedSink
...
@@ -35,8 +35,6 @@ import okio.BufferedSink
import
java.io.EOFException
import
java.io.EOFException
import
java.nio.charset.Charset
import
java.nio.charset.Charset
import
java.util.*
import
java.util.*
import
kotlin.collections.ArrayList
import
kotlin.collections.HashMap
/**
/**
...
@@ -142,8 +140,8 @@ class HttpConfig {
...
@@ -142,8 +140,8 @@ class HttpConfig {
commonParams
(),
commonParams
(),
requestHead
(
appName
),
requestHead
(
appName
),
addEncryptionHeaderParamsInterceptor
(),
addEncryptionHeaderParamsInterceptor
(),
responseErrorInterceptor
()
responseErrorInterceptor
()
,
// respErrorInterceptor()
respErrorInterceptor
(),
)
)
.
setRequestHandler
(
getRequestHandler
())
.
setRequestHandler
(
getRequestHandler
())
.
setReadTimeout
(
15
)
.
setReadTimeout
(
15
)
...
@@ -193,22 +191,29 @@ class HttpConfig {
...
@@ -193,22 +191,29 @@ class HttpConfig {
val
code
=
resp
.
code
()
val
code
=
resp
.
code
()
val
message
=
resp
.
message
()
val
message
=
resp
.
message
()
val
api
=
req
.
url
().
encodedPath
()
val
api
=
req
.
url
().
encodedPath
()
if
(
api
.
contains
(
"data/bigdata/maidian/writeMaiDianData"
))
{
return
@Interceptor
resp
}
if
(!
resp
.
isSuccessful
)
{
if
(!
resp
.
isSuccessful
)
{
Apm
.
reportEventWithExt
(
"network_api"
,
"resp_fail"
,
api
,
mapOf
(
"code"
to
code
.
toString
(),
"msg"
to
message
))
Apm
.
reportEventWithExt
(
"network_api
_android
"
,
"resp_fail"
,
api
,
mapOf
(
"code"
to
code
.
toString
(),
"msg"
to
message
))
}
else
{
}
else
{
try
{
try
{
val
body
=
resp
.
body
()
?:
return
@Interceptor
resp
val
body
=
resp
.
body
()
?:
return
@Interceptor
resp
val
buffer
=
body
.
source
().
buffer
()
val
source
=
body
.
source
()
source
.
request
(
Long
.
MAX_VALUE
)
val
buffer
=
source
.
buffer
()
if
(!
isPlaintext
(
buffer
))
return
@Interceptor
resp
if
(!
isPlaintext
(
buffer
))
return
@Interceptor
resp
val
readString
=
buffer
.
clone
().
readString
(
Charset
.
forName
(
"UTF-8"
))
val
readString
=
buffer
.
clone
().
readString
(
Charset
.
forName
(
"UTF-8"
))
val
fromJson
=
Gson
().
fromJson
<
BaseAPIResponse
<
Any
>>(
readString
,
BaseAPIResponse
::
class
.
java
)
val
fromJson
=
Gson
().
fromJson
<
BaseAPIResponse
<
Any
>>(
readString
,
BaseAPIResponse
::
class
.
java
)
if
(
fromJson
==
null
)
{
return
@Interceptor
resp
}
if
(
fromJson
.
code
!=
"200"
&&
fromJson
.
code
!=
"0"
)
{
if
(
fromJson
.
code
!=
"200"
&&
fromJson
.
code
!=
"0"
)
{
Apm
.
reportEventWithExt
(
"network_api"
,
"business_fail"
,
api
,
mapOf
(
"code"
to
code
.
toString
(),
"msg"
to
message
))
Apm
.
reportEventWithExt
(
"network_api
_android
"
,
"business_fail"
,
api
,
mapOf
(
"code"
to
code
.
toString
(),
"msg"
to
message
))
}
}
}
catch
(
throwable
:
Throwable
)
{
}
catch
(
throwable
:
Throwable
)
{
LogUtil
.
e
(
throwable
.
message
)
Apm
.
reportEventWithExt
(
"network_api_android"
,
"throwable"
,
api
,
mapOf
(
"msg"
to
(
throwable
.
message
?:
""
))
)
}
}
}
}
return
@Interceptor
resp
return
@Interceptor
resp
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment