http_log 0.1.1 copy "http_log: ^0.1.1" to clipboard
http_log: ^0.1.1 copied to clipboard

A logger for HTTP requests, stores the last request, can pretty-print it in cURL or raw

example/main.dart

import 'package:http/http.dart';
import 'package:http_log/http_log.dart';

Future<void> main() async {
  final client = LoggingClient(
    Client(),
    storeLastRequest: true,
  );

  final response = await client.post(
    Uri.parse('http://httpbin.org/status/404'),
    headers: {
      'X-My-Header': 'Value',
    },
    body: 'Body',
  );

  if (response.statusCode >= 400) {
    print('Request failed:');
    print(client.lastRequest!.toRawHttpRequest());
    print(client.lastRequest!.toCurl(bodyFormat: BodyFormat.ascii));
  }
}
2
likes
160
points
21
downloads

Publisher

verified publisherainkin.com

Weekly Downloads

A logger for HTTP requests, stores the last request, can pretty-print it in cURL or raw

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT-0 (license)

Dependencies

http

More

Packages that depend on http_log