mercury_client 1.1.7 copy "mercury_client: ^1.1.7" to clipboard
mercury_client: ^1.1.7 copied to clipboard

outdated

Portable HTTP client (Browser and Native support) with memory cache and support for methods GET, POST, PUT, DELETE, PATCH and OPTIONS.

example/example.dart

import 'dart:io';

import 'package:mercury_client/mercury_client.dart';

void main() async {
  print('------------------------------------------------');

  var client = HttpClient('https://www.google.com/');

  // GET: https://www.google.com/search?q=mercury_client
  var response =
      await client.get('search', parameters: {'q': 'mercury_client'});

  if (response.isOK) {
    var ok = response.body.contains('<html');
    print('Request OK: $ok');
    print(response);
    print('Body Type: ${response.bodyType}\n');
    print('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<');
    print(response.body);
    print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n');
  } else {
    print('Response Error!');
    print(response);
  }

  print('------------------------------------------------');

  var responsePost =
      await client.post('search', parameters: {'q': 'mercury_client'});
  assert(responsePost.isError);

  print('Google rejects POST requests!');
  print(responsePost);

  print('------------------------------------------------\n');

  print('By!');

  exit(0);
}
15
likes
0
points
2.07k
downloads

Publisher

unverified uploader

Weekly Downloads

Portable HTTP client (Browser and Native support) with memory cache and support for methods GET, POST, PUT, DELETE, PATCH and OPTIONS.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

enum_to_string, swiss_knife

More

Packages that depend on mercury_client