Skip to content

Commit d239a75

Browse files
committed
update dependencies
1 parent c35f9ad commit d239a75

File tree

7 files changed

+319
-319
lines changed

7 files changed

+319
-319
lines changed

lib/src/client.dart

+25-25
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ import 'package:http_parser/http_parser.dart';
88
import 'urls.dart';
99
import 'xdnmb.dart';
1010

11-
/// 将cookie列表转化为cookie值
11+
/// 将 cookie 列表转化为 cookie 值
1212
String _toCookies(Iterable<String> cookies) => cookies.join('; ');
1313

14-
/// [Response]的扩展
14+
/// [Response] 的扩展
1515
extension ResponseExtension on Response {
16-
/// 返回utf8编码的[body],不用[body]是因为X岛返回的header可能不包含编码信息
16+
/// 返回 utf8 编码的 [body],不用 [body] 是因为 X 岛返回的 header 可能不包含编码信息
1717
/// 这样解码会出错
1818
String get utf8Body => utf8.decode(bodyBytes);
1919
}
2020

21-
/// HTTP状态异常
21+
/// HTTP 状态异常
2222
class HttpStatusException implements Exception {
2323
/// 状态码
2424
final int statusCode;
2525

26-
/// 构造[HttpStatusException]
26+
/// 构造 [HttpStatusException]
2727
const HttpStatusException(this.statusCode);
2828

2929
@override
@@ -39,14 +39,14 @@ class HttpStatusException implements Exception {
3939
int get hashCode => statusCode.hashCode;
4040
}
4141

42-
/// multipart的实现
42+
/// multipart 的实现
4343
class Multipart extends MultipartRequest {
44-
/// 构造[Multipart]
44+
/// 构造 [Multipart]
4545
///
46-
/// [url]为请求链接
46+
/// [url] 为请求链接
4747
Multipart(Uri url) : super('POST', url);
4848

49-
/// 添加字段,值为[value]的字符串表达
49+
/// 添加字段,值为 [value] 的字符串表达
5050
void add(String field, Object value) => fields[field] = value.toString();
5151

5252
/// 添加字段
@@ -63,7 +63,7 @@ class Multipart extends MultipartRequest {
6363
);
6464
}
6565

66-
/// HTTP client的实现
66+
/// HTTP client 的实现
6767
class Client extends IOClient {
6868
/// 默认连接超时时长
6969
static const Duration defaultConnectionTimeout = Duration(seconds: 15);
@@ -74,19 +74,19 @@ class Client extends IOClient {
7474
/// 默认`User-Agent`
7575
static const String _defaultUserAgent = 'xdnmb';
7676

77-
/// X岛的PHP session ID
77+
/// X 岛的 PHP session ID
7878
String? xdnmbPhpSessionId;
7979

80-
/// X岛备用API的PHP session ID
80+
/// X 岛备用 API 的 PHP session ID
8181
String? _xdnmbBackupApiPhpSessionId;
8282

83-
/// 构造[Client]
83+
/// 构造 [Client]
8484
///
85-
/// [client][HttpClient]
85+
/// [client][HttpClient]
8686
///
87-
/// [connectionTimeout]为连接超时时长,默认为15秒
87+
/// [connectionTimeout] 为连接超时时长,默认为 15 秒
8888
///
89-
/// [idleTimeout]为连接空闲超时时长,默认为90秒
89+
/// [idleTimeout] 为连接空闲超时时长,默认为 90 秒
9090
Client(
9191
{HttpClient? client,
9292
Duration? connectionTimeout,
@@ -97,15 +97,15 @@ class Client extends IOClient {
9797
..idleTimeout = idleTimeout ?? _defaultIdleTimeout
9898
..userAgent = userAgent ?? _defaultUserAgent);
9999

100-
/// [xdnmbPhpSessionId]有效
100+
/// [xdnmbPhpSessionId] 有效
101101
bool _xdnmbPhpSessionIdIsValid(Uri url) =>
102102
xdnmbPhpSessionId != null && XdnmbUrls().isBaseUrl(url);
103103

104-
/// [_xdnmbBackupApiPhpSessionId]有效
104+
/// [_xdnmbBackupApiPhpSessionId] 有效
105105
bool _xdnmbBackupApiPhpSessionIdIsValid(Uri url) =>
106106
_xdnmbBackupApiPhpSessionId != null && XdnmbUrls().isBackupApiUrl(url);
107107

108-
/// 返回cookie头
108+
/// 返回 cookie 头
109109
Map<String, String>? _cookieHeasers(Uri url, String? cookie) =>
110110
(cookie != null ||
111111
_xdnmbPhpSessionIdIsValid(url) ||
@@ -120,15 +120,15 @@ class Client extends IOClient {
120120
}
121121
: null;
122122

123-
/// GET请求
123+
/// GET 请求
124124
Future<Response> xGet(Uri url, [String? cookie]) async {
125125
final response = await this.get(url, headers: _cookieHeasers(url, cookie));
126126
_checkStatusCode(response);
127127

128128
return response;
129129
}
130130

131-
/// POST form请求
131+
/// POST form 请求
132132
Future<Response> xPostForm(Uri url, Map<String, String>? form,
133133
[String? cookie]) async {
134134
final response =
@@ -138,7 +138,7 @@ class Client extends IOClient {
138138
return response;
139139
}
140140

141-
/// POST multipart请求
141+
/// POST multipart 请求
142142
Future<Response> xPostMultipart(Multipart multipart, [String? cookie]) async {
143143
if (cookie != null ||
144144
_xdnmbPhpSessionIdIsValid(multipart.url) ||
@@ -161,7 +161,7 @@ class Client extends IOClient {
161161
Future<IOStreamedResponse> send(BaseRequest request) async {
162162
final response = await super.send(request);
163163

164-
// 获取xdnmbPhpSessionId和_xdnmbBackupApiPhpSessionId
164+
// 获取 xdnmbPhpSessionId 和_xdnmbBackupApiPhpSessionId
165165
final setCookie = response.headers[HttpHeaders.setCookieHeader];
166166
if (setCookie != null) {
167167
final cookies = setCookie.split(RegExp(r',(?! )'));
@@ -177,7 +177,7 @@ class Client extends IOClient {
177177
}
178178
}
179179
} catch (e) {
180-
print('解析set-cookie出现错误:$e');
180+
print('解析 set-cookie 出现错误:$e');
181181
}
182182
}
183183
}
@@ -186,7 +186,7 @@ class Client extends IOClient {
186186
}
187187
}
188188

189-
/// 检查HTTP状态码
189+
/// 检查 HTTP 状态码
190190
void _checkStatusCode(Response response) {
191191
if (response.statusCode != HttpStatus.ok) {
192192
throw HttpStatusException(response.statusCode);

lib/src/cookie.dart

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
part of 'xdnmb.dart';
22

3-
/// X岛饼干
3+
/// X 岛饼干
44
class XdnmbCookie {
5-
/// 饼干的userhash
5+
/// 饼干的 userhash
66
final String userHash;
77

88
/// 饼干显示的名字
99
final String? name;
1010

11-
/// 饼干ID
11+
/// 饼干 ID
1212
final int? id;
1313

14-
/// 饼干的cookie值
14+
/// 饼干的 cookie 值
1515
String get cookie => 'userhash=$userHash';
1616

17-
/// 构造[XdnmbCookie]
17+
/// 构造 [XdnmbCookie]
1818
const XdnmbCookie(this.userHash, {this.name, this.id});
1919

20-
/// 从JSON数据构造[XdnmbCookie]
20+
/// 从 JSON 数据构造 [XdnmbCookie]
2121
factory XdnmbCookie._fromJson(String data, {int? id}) {
2222
final Map<String, dynamic> decoded = json.decode(data);
2323

@@ -47,19 +47,19 @@ class CookiesList {
4747
/// 帐号能够拥有的最大饼干数(饼干槽)
4848
final int totalCookiesNum;
4949

50-
/// 帐号饼干ID列表
50+
/// 帐号饼干 ID 列表
5151
final List<int> cookiesIdList;
5252

53-
/// 构造[CookiesList]
53+
/// 构造 [CookiesList]
5454
const CookiesList(
5555
{required this.canGetCookie,
5656
required this.currentCookiesNum,
5757
required this.totalCookiesNum,
5858
required this.cookiesIdList});
5959
}
6060

61-
/// [Cookie]的扩展
61+
/// [Cookie] 的扩展
6262
extension CookieExtension on Cookie {
63-
/// 将[Cookie]转化为cookie值
63+
/// 将 [Cookie] 转化为 cookie 值
6464
String get toCookie => '$name=$value';
6565
}

0 commit comments

Comments
 (0)