-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made HttpHeader names case-insensitive and added tests
- Loading branch information
1 parent
d791b30
commit bd4dde1
Showing
2 changed files
with
125 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'package:kiota_abstractions/kiota_abstractions.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test('HttpHeader keys are case-insensitive', () { | ||
final headers = HttpHeaders()..['content-type'] = 'application/json'; | ||
|
||
expect(headers.length, 1); | ||
expect(headers['content-type'], 'application/json'); | ||
expect(headers['Content-Type'], 'application/json'); | ||
|
||
headers['Content-Type'] = 'application/xml'; | ||
|
||
expect(headers.length, 1); | ||
expect(headers['content-type'], 'application/xml'); | ||
expect(headers['Content-Type'], 'application/xml'); | ||
|
||
// should not get added as a new key | ||
headers.putIfAbsent('CONTENT-TYPE', () => 'application/json'); | ||
|
||
expect(headers.length, 1); | ||
expect(headers['CONTENT-TYPE'], 'application/xml'); | ||
}); | ||
|
||
test('HttpHeader preserves original case', () { | ||
final headers = HttpHeaders(); | ||
|
||
headers['Content-Type'] = 'application/json'; | ||
|
||
expect(headers.keys.first, 'Content-Type'); | ||
|
||
// This should overwrite the previous key | ||
headers['content-type'] = 'application/xml'; | ||
|
||
expect(headers.keys.first, 'content-type'); | ||
}); | ||
} |