Skip to content

Commit

Permalink
fix http non default port bug (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghongenpin committed Dec 15, 2024
1 parent a039d31 commit a8acceb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/network/http/codec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ class HttpRequestCodec extends HttpCodec<HttpRequest> {
String uri = message.uri;

//http scheme 输入地址和host不一致
if (uri.startsWith(HostAndPort.httpScheme) && message.requestUri?.host != message.headers.host) {
if (uri.startsWith(HostAndPort.httpScheme) &&
(message.requestUri?.host != message.headers.host && message.headers.host?.contains(':') != true)) {
uri = message.requestUri?.replace(host: message.headers.host).toString() ?? uri;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/network/http_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class HttpClients {
Channel channel =
await proxyConnect(proxyInfo: proxyInfo, request.hostAndPort!, httpResponseHandler, channelContext);

if (channel.isSsl && !request.uri.startsWith("/")) {
if (!request.uri.startsWith("/")) {
Uri? uri = request.requestUri;
request = request.copy(uri: '${uri!.path}${uri.hasQuery ? '?${uri.query}' : ''}');
}
Expand Down
4 changes: 3 additions & 1 deletion lib/ui/desktop/request/request_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import 'package:proxypin/network/host_port.dart';
import 'package:proxypin/network/http/http.dart';
import 'package:proxypin/network/http/http_headers.dart';
import 'package:proxypin/network/http_client.dart';
import 'package:proxypin/network/util/logger.dart';
import 'package:proxypin/ui/component/split_view.dart';
import 'package:proxypin/ui/component/state_component.dart';
import 'package:proxypin/ui/content/body.dart';
Expand Down Expand Up @@ -174,7 +175,8 @@ class RequestEditorState extends State<RequestEditor> {
responseKey.currentState?.change(response);
responseChange.value = 1;
// if (mounted) FlutterToastr.show(localizations.requestSuccess, context);
}).catchError((e) {
}).catchError((e, stackTrace) {
logger.e("Request failed", error: e, stackTrace: stackTrace);
responseChange.value = -1;
if (mounted) FlutterToastr.show('${localizations.fail}$e', context);
});
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ dependencies:
intl: any
cupertino_icons: ^1.0.8
pointycastle: ^3.9.1
logger: ^2.4.0
logger: ^2.5.0
date_format: ^2.0.9
window_manager: ^0.4.3
desktop_multi_window:
git:
url: https://gitee.com/wanghongenpin/flutter-plugins.git
path: packages/desktop_multi_window
path_provider: ^2.1.5
file_picker: ^8.1.3
file_picker: ^8.1.5
proxy_manager: ^0.0.3
permission_handler: ^11.3.1
flutter_toastr: ^1.0.3
Expand Down

0 comments on commit a8acceb

Please sign in to comment.