[skip ci]
This commit is contained in:
@@ -77,6 +77,21 @@ object UrlUtil {
|
|||||||
conn.instanceFollowRedirects = false
|
conn.instanceFollowRedirects = false
|
||||||
conn.connect()
|
conn.connect()
|
||||||
|
|
||||||
|
if (AppConfig.recordLog || BuildConfig.DEBUG) {
|
||||||
|
val headers = conn.headerFields
|
||||||
|
val headersString = buildString {
|
||||||
|
headers.forEach { (key, value) ->
|
||||||
|
value.forEach {
|
||||||
|
append(key ? "HEAD ${url.toString}")
|
||||||
|
append(": ")
|
||||||
|
append(it)
|
||||||
|
append("\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AppLog.put("${url.toString()} response header:\n$headersString")
|
||||||
|
}
|
||||||
|
|
||||||
// val fileSize = conn.getContentLengthLong() / 1024
|
// val fileSize = conn.getContentLengthLong() / 1024
|
||||||
/** Content-Disposition 存在三种情况 文件名应该用引号 有些用空格
|
/** Content-Disposition 存在三种情况 文件名应该用引号 有些用空格
|
||||||
* filename="filename"
|
* filename="filename"
|
||||||
@@ -114,21 +129,7 @@ object UrlUtil {
|
|||||||
val newUrl= URL(URLDecoder.decode(redirectUrl, "UTF-8"))
|
val newUrl= URL(URLDecoder.decode(redirectUrl, "UTF-8"))
|
||||||
getFileNameFromPath(newUrl)
|
getFileNameFromPath(newUrl)
|
||||||
} else {
|
} else {
|
||||||
AppLog.put("Cannot obtain URL file name, enable recordLog for detail")
|
AppLog.put("Cannot obtain URL file name, enable recordLog for response header")
|
||||||
if (AppConfig.recordLog || BuildConfig.DEBUG) {
|
|
||||||
val headers = conn.headerFields
|
|
||||||
val headersString = buildString {
|
|
||||||
headers.forEach { (key, value) ->
|
|
||||||
value.forEach {
|
|
||||||
append(key)
|
|
||||||
append(": ")
|
|
||||||
append(it)
|
|
||||||
append("\n")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AppLog.put("${url.toString()} response header:\n$headersString")
|
|
||||||
}
|
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user