mirror of
https://github.com/amir1376/ab-download-manager.git
synced 2025-02-20 11:43:24 +08:00
add default first/last headers to downloader client
This commit is contained in:
parent
78e5f28e5c
commit
8bf289c478
@ -18,6 +18,7 @@
|
||||
- App is now open in center of screen
|
||||
- Some settings doesn't persist after app restart
|
||||
- Download speed shows a high value incorrectly when we reopen the app window after a while
|
||||
- Some files not downloaded correctly now fixed
|
||||
|
||||
### Security
|
||||
|
||||
|
@ -4,7 +4,17 @@ import ir.amirab.downloader.connection.response.ResponseInfo
|
||||
import ir.amirab.downloader.downloaditem.IDownloadCredentials
|
||||
|
||||
abstract class DownloaderClient {
|
||||
fun defaultHeaders() = linkedMapOf(
|
||||
/**
|
||||
* these headers will be placed at first and maybe overridden by another header
|
||||
*/
|
||||
fun defaultHeadersInFirst() = linkedMapOf<String,String>(
|
||||
//empty for now!
|
||||
)
|
||||
|
||||
/**
|
||||
* these headers will be added after others so they override existing headers
|
||||
*/
|
||||
fun defaultHeadersInLast() = linkedMapOf(
|
||||
"accept-encoding" to "identity",
|
||||
)
|
||||
|
||||
|
@ -19,7 +19,7 @@ class OkHttpDownloaderClient(
|
||||
Request.Builder()
|
||||
.url(downloadCredentials.link)
|
||||
.apply {
|
||||
defaultHeaders().forEach { (k, v) ->
|
||||
defaultHeadersInFirst().forEach { (k, v) ->
|
||||
header(k, v)
|
||||
}
|
||||
downloadCredentials.headers
|
||||
@ -31,6 +31,9 @@ class OkHttpDownloaderClient(
|
||||
?.forEach { (k, v) ->
|
||||
header(k, v)
|
||||
}
|
||||
defaultHeadersInLast().forEach { (k, v) ->
|
||||
header(k, v)
|
||||
}
|
||||
val username = downloadCredentials.username
|
||||
val password = downloadCredentials.password
|
||||
if (username?.isNotBlank() == true && password?.isNotBlank() == true) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user