Skip to content

Commit 4dc5a0e

Browse files
committed
refactor: move SentryRequest cookie discovery to a single place & make case insensitive
1 parent 8f551ef commit 4dc5a0e

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

dart/lib/src/http_client/failed_request_client.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ class FailedRequestClient extends BaseClient {
166166
headers: sendDefaultPii ? request.headers : null,
167167
url: urlWithoutQuery,
168168
queryString: query,
169-
cookies: sendDefaultPii ? request.headers['Cookie'] : null,
170169
data: sendDefaultPii ? _getDataFromRequest(request) : null,
171170
// ignore: deprecated_member_use_from_same_package
172171
other: {

dart/lib/src/protocol/sentry_request.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import 'package:meta/meta.dart';
22

3+
import '../utils/iterable_extension.dart';
4+
35
/// The Request interface contains information on a HTTP request related to the event.
46
/// In client SDKs, this can be an outgoing request, or the request that rendered the current web page.
57
/// On server SDKs, this could be the incoming web request that is being handled.
@@ -63,14 +65,19 @@ class SentryRequest {
6365
this.url,
6466
this.method,
6567
this.queryString,
66-
this.cookies,
68+
String? cookies,
6769
this.fragment,
6870
dynamic data,
6971
Map<String, String>? headers,
7072
Map<String, String>? env,
7173
@Deprecated('Will be removed in v7.') Map<String, String>? other,
7274
}) : _data = data,
7375
_headers = headers != null ? Map.from(headers) : null,
76+
// Look for a 'Set-Cookie' header (case insensitive) if not given.
77+
cookies = cookies ??
78+
headers?.entries
79+
.firstWhereOrNull((e) => e.key.toLowerCase() == 'cookie')
80+
?.value,
7481
_env = env != null ? Map.from(env) : null,
7582
_other = other != null ? Map.from(other) : null;
7683

dio/lib/src/dio_event_processor.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ class DioEventProcessor implements EventProcessor {
131131
headers: _options.sendDefaultPii ? headers : null,
132132
url: urlWithoutQuery,
133133
queryString: query,
134-
cookies: _options.sendDefaultPii
135-
? options.headers['Cookie']?.toString()
136-
: null,
137134
data: _getRequestData(dioError.requestOptions.data),
138135
);
139136
}

0 commit comments

Comments
 (0)