-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #2002 #1102 #788 #641 ### New Pull Request Checklist - [x] I have read the [Documentation](https://pub.dev/documentation/dio/latest/) - [x] I have searched for a similar pull request in the [project](https://github.com/cfug/dio/pulls) and found none - [x] I have updated this branch with the latest `main` branch to avoid conflicts (via merge from master or rebase) - [x] I have added the required tests to prove the fix/feature I'm adding - [x] I have updated the documentation (if necessary) - [x] I have run the tests without failures - [x] I have updated the `CHANGELOG.md` in the corresponding package ### Additional context and info (if any) We have `camelCaseContentDisposition` for `FormData` but this is not related. --------- Signed-off-by: Alex Li <[email protected]>
- Loading branch information
Showing
13 changed files
with
220 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:dio/dio.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group(Headers, () { | ||
test('set', () { | ||
final headers = Headers.fromMap({ | ||
'set-cookie': ['k=v', 'k1=v1'], | ||
'content-length': ['200'], | ||
'test': ['1', '2'], | ||
}); | ||
headers.add('SET-COOKIE', 'k2=v2'); | ||
expect(headers.value('content-length'), '200'); | ||
expect(Future(() => headers.value('test')), throwsException); | ||
expect(headers['set-cookie']?.length, 3); | ||
headers.remove('set-cookie', 'k=v'); | ||
expect(headers['set-cookie']?.length, 2); | ||
headers.removeAll('set-cookie'); | ||
expect(headers['set-cookie'], isNull); | ||
final ls = []; | ||
headers.forEach((k, list) => ls.addAll(list)); | ||
expect(ls.length, 3); | ||
expect(headers.toString(), 'content-length: 200\ntest: 1\ntest: 2\n'); | ||
headers.set('content-length', '300'); | ||
expect(headers.value('content-length'), '300'); | ||
headers.set('content-length', ['400']); | ||
expect(headers.value('content-length'), '400'); | ||
}); | ||
|
||
test('clear', () { | ||
final headers1 = Headers(); | ||
headers1.set('xx', 'v'); | ||
expect(headers1.value('xx'), 'v'); | ||
headers1.clear(); | ||
expect(headers1.map.isEmpty, isTrue); | ||
}); | ||
|
||
test('case-sensitive', () { | ||
final headers = Headers.fromMap( | ||
{ | ||
'SET-COOKIE': ['k=v', 'k1=v1'], | ||
'content-length': ['200'], | ||
'Test': ['1', '2'], | ||
}, | ||
preserveHeaderCase: true, | ||
); | ||
expect(headers['SET-COOKIE']?.length, 2); | ||
// Although it's case-sensitive, we still use case-insensitive map. | ||
expect(headers['set-cookie']?.length, 2); | ||
expect(headers['content-length']?.length, 1); | ||
expect(headers['Test']?.length, 2); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.