Skip to content

Commit

Permalink
fix(dynamite_runtime): Stop sending empty cookies
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <kate@provokateurin.de>
  • Loading branch information
provokateurin committed Jan 20, 2024
1 parent 3e5eb9b commit bce8c76
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,9 @@ class DynamiteClient {

if (cookieJar != null) {
final cookies = await cookieJar!.loadForRequest(uri);
request.headers['cookie'] = cookies.join('; ');
if (cookies.isNotEmpty) {
request.headers['cookie'] = cookies.join('; ');
}
}

final response = await httpClient.send(request);
Expand Down
15 changes: 15 additions & 0 deletions packages/dynamite/dynamite_runtime/test/client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,19 @@ void main() {
expect(cookies[1].name, 'c');
expect(cookies[1].value, 'd');
});

test('No cookies', () async {
final mockedClient = MockClient((request) async {
expect(request.headers['cookie'], isNull);
return Response('', 200);
});

final client = DynamiteClient(
uri,
httpClient: mockedClient,
cookieJar: cookieJar,
);

await client.executeRequest('GET', '', {}, null, null);
});
}

0 comments on commit bce8c76

Please sign in to comment.