Skip to content

Commit ce43a7e

Browse files
committed
ix Stream issue in Safari browser,
1 parent 126d144 commit ce43a7e

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.1
2+
3+
* Fix Stream issue in Safari browser, for now it will wait for chunks to be completed. This will be fixed when `dart:http` fix the streamed response issue in Web
4+
15
## 1.1.0
26

37
* Fix HTTP Stream on Web

lib/src/stream_client_web.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
import 'package:http/http.dart' as http;
22
import 'stream_client.dart';
33
import 'package:fetch_client/fetch_client.dart';
4+
import 'package:web_browser_detect/web_browser_detect.dart';
45

56
class StreamClientWeb extends StreamClient {
67
@override
78
Future<http.StreamedResponse> send(http.BaseRequest request) {
8-
final client = FetchClient(mode: RequestMode.cors, streamRequests: true);
9-
return client.send(request);
9+
final browser = Browser().browser;
10+
final isSafariBrowser =
11+
browser.indexOf("Safari") > -1 && browser.indexOf("Chrome") <= -1;
12+
if (isSafariBrowser) {
13+
return http.Client().send(request);
14+
} else {
15+
final client = FetchClient(mode: RequestMode.cors, streamRequests: true);
16+
return client.send(request);
17+
}
1018
}
1119
}
1220

pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: chatgpt_client
22
description: Access OpenAI ChatGPT Public API using Dart Language. Supports native Dart project and all Flutter target platforms (iOS, Android, Windows, Linux, Web)
3-
version: 1.1.0
3+
version: 1.1.1
44
homepage: https://github.com/alfianlosari/chatgpt_api_dart
55

66
environment:
@@ -9,6 +9,7 @@ environment:
99
dependencies:
1010
http: ^0.13.5
1111
fetch_client: ^1.0.0
12+
web_browser_detect: ^2.0.3
1213

1314
dev_dependencies:
1415
test: ^1.23.1

0 commit comments

Comments
 (0)