diff --git a/pkgs/cronet_http/example/integration_test/cronet_configuration_test.dart b/pkgs/cronet_http/example/integration_test/cronet_configuration_test.dart index f787ebc39a..4372e85432 100644 --- a/pkgs/cronet_http/example/integration_test/cronet_configuration_test.dart +++ b/pkgs/cronet_http/example/integration_test/cronet_configuration_test.dart @@ -2,9 +2,11 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'dart:convert'; import 'dart:io'; import 'package:cronet_http/cronet_http.dart'; +import 'package:http/http.dart'; import 'package:integration_test/integration_test.dart'; import 'package:test/test.dart'; @@ -92,6 +94,49 @@ void testInvalidConfigurations() { }); } +void testMethods() { + group('methods', () { + late HttpServer server; + late String requestMethod; + + setUp(() async { + server = (await HttpServer.bind('localhost', 0)) + ..listen((request) async { + await request.drain(); + requestMethod = request.method; + await request.response.close(); + }); + }); + tearDown(() { + server.close(); + }); + + test('methods', () async { + final engine = CronetEngine.build(); + const methods = [ + 'GET', + 'HEAD', + 'POST', + 'PUT', + 'DELETE', + 'CONNECT', + 'OPTIONS', + 'TRACE', + 'PATCH', + 'CUSTOM', + ]; + for (final method in methods) { + final request = Request( + method, + Uri.parse('http://localhost:${server.port}'), + ); + await CronetClient.fromCronetEngine(engine).send(request); + expect(requestMethod, method); + } + }); + }); +} + void testUserAgent() { group('userAgent', () { late HttpServer server;