What changed, and why it matters
This commit is a minor code cleanup in a Dart HTTP helper class. It adds a constant constructor and reformats some code onto fewer lines. There is no change to behavior, no bug fix, and no security relevance visible in the diff.
No security action needed. Treat as a routine refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds const HTTP(); to the HTTP class and removes unnecessary trailing commas and line breaks in method signatures and constructor calls. The logic for get, post, and _bodyBytes remains identical. No functional or security-relevant changes are present.
Changed components
lib/networking/http.dartInspect captured patch +11 / −33
diff --git a/lib/networking/http.dart b/lib/networking/http.dart
index 80ea57c..48b5f1c 100644
--- a/lib/networking/http.dart
+++ b/lib/networking/http.dart
@@ -20,27 +20,21 @@ class Response {
}
class HTTP {
+ const HTTP();
+
Future<Response> get({
required Uri url,
Map<String, String>? headers,
- required ({
- InternetAddress host,
- int port,
- })? proxyInfo,
+ required ({InternetAddress host, int port})? proxyInfo,
}) async {
final httpClient = HttpClient();
try {
if (proxyInfo != null) {
SocksTCPClient.assignToHttpClient(httpClient, [
- ProxySettings(
- proxyInfo.host,
- proxyInfo.port,
- ),
+ ProxySettings(proxyInfo.host, proxyInfo.port),
]);
}
- final HttpClientRequest request = await httpClient.getUrl(
- url,
- );
+ final HttpClientRequest request = await httpClient.getUrl(url);
if (headers != null) {
headers.forEach((key, value) => request.headers.add(key, value));
@@ -48,10 +42,7 @@ class HTTP {
final response = await request.close();
- return Response(
- await _bodyBytes(response),
- response.statusCode,
- );
+ return Response(await _bodyBytes(response), response.statusCode);
} catch (e, s) {
Logging.instance.w("HTTP.get() rethrew: ", error: e, stackTrace: s);
rethrow;
@@ -65,24 +56,16 @@ class HTTP {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
- required ({
- InternetAddress host,
- int port,
- })? proxyInfo,
+ required ({InternetAddress host, int port})? proxyInfo,
}) async {
final httpClient = HttpClient();
try {
if (proxyInfo != null) {
SocksTCPClient.assignToHttpClient(httpClient, [
- ProxySettings(
- proxyInfo.host,
- proxyInfo.port,
- ),
+ ProxySettings(proxyInfo.host, proxyInfo.port),
]);
}
- final HttpClientRequest request = await httpClient.postUrl(
- url,
- );
+ final HttpClientRequest request = await httpClient.postUrl(url);
if (headers != null) {
headers.forEach((key, value) => request.headers.add(key, value));
@@ -91,10 +74,7 @@ class HTTP {
request.write(body);
final response = await request.close();
- return Response(
- await _bodyBytes(response),
- response.statusCode,
- );
+ return Response(await _bodyBytes(response), response.statusCode);
} catch (e, s) {
Logging.instance.w("HTTP.post() rethrew: ", error: e, stackTrace: s);
rethrow;
@@ -110,9 +90,7 @@ class HTTP {
(data) {
bytes.addAll(data);
},
- onDone: () => completer.complete(
- Uint8List.fromList(bytes),
- ),
+ onDone: () => completer.complete(Uint8List.fromList(bytes)),
onError: (Object err, StackTrace s) => Logging.instance.e(
"Http wrapper layer listen",
error: err,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.