|
@@ -77,21 +77,6 @@ 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)
|
|
|
|
|
- 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"
|
|
@@ -113,12 +98,15 @@ object UrlUtil {
|
|
|
val data = fileName.split("''")
|
|
val data = fileName.split("''")
|
|
|
names.add(URLDecoder.decode(data[1], data[0]))
|
|
names.add(URLDecoder.decode(data[1], data[0]))
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ names.add(fileName)
|
|
|
|
|
+ /* 好像不用这样
|
|
|
names.add(
|
|
names.add(
|
|
|
String(
|
|
String(
|
|
|
fileName.toByteArray(StandardCharsets.ISO_8859_1),
|
|
fileName.toByteArray(StandardCharsets.ISO_8859_1),
|
|
|
StandardCharsets.UTF_8
|
|
StandardCharsets.UTF_8
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
|
|
+ */
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
names.firstOrNull()
|
|
names.firstOrNull()
|
|
@@ -127,6 +115,20 @@ object UrlUtil {
|
|
|
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 detail")
|
|
|
|
|
+ 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
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -156,4 +158,4 @@ object UrlUtil {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
+}
|