diff --git a/README.md b/README.md index a96d73b0..6773c74a 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ [![Donate](https://img.shields.io/badge/%24-donate-ff69b4.svg)](https://docs.gopeed.com/donate.html) [![Discord](https://img.shields.io/discord/1037992631881449472?label=Discord&logo=discord&style=social)](https://discord.gg/ZUJqJrwCGB) +GopeedLab%2Fgopeed | Trendshift + ![](_docs/img/banner.png) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R6IJGN6) diff --git a/README_ja-JP.md b/README_ja-JP.md index f9873e57..18e9094f 100644 --- a/README_ja-JP.md +++ b/README_ja-JP.md @@ -5,6 +5,8 @@ [![Donate](https://img.shields.io/badge/%24-donate-ff69b4.svg)](https://docs.gopeed.com/donate.html) [![Discord](https://img.shields.io/discord/1037992631881449472?label=Discord&logo=discord&style=social)](https://discord.gg/ZUJqJrwCGB) +GopeedLab%2Fgopeed | Trendshift + ![](_docs/img/banner.png) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R6IJGN6) diff --git a/README_vi-VN.md b/README_vi-VN.md index 7c8ce369..167a5581 100644 --- a/README_vi-VN.md +++ b/README_vi-VN.md @@ -5,6 +5,8 @@ [![Ủng hộ](https://img.shields.io/badge/%24-ủng%20hộ-ff69b4.svg)](https://docs.gopeed.com/donate.html) [![Discord](https://img.shields.io/discord/1037992631881449472?label=Discord&logo=discord&style=social)](https://discord.gg/ZUJqJrwCGB) +GopeedLab%2Fgopeed | Trendshift + ![](_docs/img/banner.png) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R6IJGN6) diff --git a/README_zh-CN.md b/README_zh-CN.md index 4ec1327b..22e0c64a 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -5,6 +5,8 @@ [![Donate](https://img.shields.io/badge/%24-donate-ff69b4.svg)](https://docs.gopeed.com/zh/donate.html) [![Discord](https://img.shields.io/discord/1037992631881449472?label=Discord&logo=discord&style=social)](https://discord.gg/ZUJqJrwCGB) +GopeedLab%2Fgopeed | Trendshift + ![](_docs/img/banner.png) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R6IJGN6) diff --git a/README_zh-TW.md b/README_zh-TW.md index 147d6004..062dc9dc 100644 --- a/README_zh-TW.md +++ b/README_zh-TW.md @@ -5,6 +5,8 @@ [![Donate](https://img.shields.io/badge/%24-donate-ff69b4.svg)](https://docs.gopeed.com/donate.html) [![Discord](https://img.shields.io/discord/1037992631881449472?label=Discord&logo=discord&style=social)](https://discord.gg/ZUJqJrwCGB) +GopeedLab%2Fgopeed | Trendshift + ![](_docs/img/banner.png) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R6IJGN6) diff --git a/internal/protocol/http/fetcher.go b/internal/protocol/http/fetcher.go index bda1a457..d03fe984 100644 --- a/internal/protocol/http/fetcher.go +++ b/internal/protocol/http/fetcher.go @@ -405,7 +405,7 @@ func (f *Fetcher) buildRequest(ctx context.Context, req *base.Request) (httpReq body = bytes.NewBufferString(extra.Body) } } - if _, ok := headers[base.HttpHeaderUserAgent]; !ok { + if v := headers[base.HttpHeaderUserAgent]; len(v) == 0 || v[0] == "" { // load user agent from config headers[base.HttpHeaderUserAgent] = []string{f.config.UserAgent} } diff --git a/ui/flutter/lib/app/modules/create/views/create_view.dart b/ui/flutter/lib/app/modules/create/views/create_view.dart index b678992a..394350d6 100644 --- a/ui/flutter/lib/app/modules/create/views/create_view.dart +++ b/ui/flutter/lib/app/modules/create/views/create_view.dart @@ -396,7 +396,7 @@ class CreateView extends GetView { Util.isWeb() && controller.fileDataUri.isNotEmpty; final submitUrl = isWebFileChosen ? controller.fileDataUri.value - : _urlController.text; + : _urlController.text.trim(); final urls = Util.textToLines(submitUrl); // Add url to the history @@ -443,17 +443,24 @@ class CreateView extends GetView { Object? parseReqExtra(String url) { Object? reqExtra; if (controller.showAdvanced.value) { - final u = Uri.parse(_urlController.text); - if (u.scheme.startsWith("http")) { - reqExtra = ReqExtraHttp() - ..header = { + switch (controller.advancedTabController.index) { + case 0: + final header = { "User-Agent": _httpUaController.text, "Cookie": _httpCookieController.text, "Referer": _httpRefererController.text, }; - } else { - reqExtra = ReqExtraBt() - ..trackers = Util.textToLines(_btTrackerController.text); + header.removeWhere((key, value) => value.trim().isEmpty); + if (header.isNotEmpty) { + reqExtra = ReqExtraHttp()..header = header; + } + break; + case 1: + if (_btTrackerController.text.trim().isNotEmpty) { + reqExtra = ReqExtraBt() + ..trackers = Util.textToLines(_btTrackerController.text); + } + break; } } return reqExtra;