Skip to content
This repository was archived by the owner on Mar 18, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions aqueduct_test/lib/src/request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,19 @@ class TestRequest {

var url = _baseUrl.resolve(actualPath).toString();
if ((query?.length ?? 0) > 0) {
final pairs = query.keys.map((key) {
final val = query[key];
final pairs = <String>[];

query.forEach((key, val) {
if (val == null || val == true) {
return "$key";
pairs.add("$key");
} else if (val is List) {
val.forEach((innerVal) {
final urlEncoded = Uri.encodeComponent('$innerVal');
pairs.add("$key=$urlEncoded");
});
} else {
return "$key=${Uri.encodeComponent("$val")}";
final urlEncoded = Uri.encodeComponent('$val');
pairs.add("$key=$urlEncoded");
}
});

Expand Down
11 changes: 11 additions & 0 deletions aqueduct_test/test/request_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ void main() {
expect(received.raw.uri.query, "k=v%20v");
});

test("List query parameters are encoded as separate keys", () async {
final req = agent.request("/")
..query = {
"k": ["v", "w"]
};
await req.get();

final received = await server.next();
expect(received.raw.uri.query, "k=v&k=w");
});

test("Headers get added to request", () async {
final req = agent.request("/")
..headers["k"] = "v"
Expand Down