<commit_before><?php

use Amp\Artax\Response;
use Amp\Loop;

require __DIR__ . '/../vendor/autoload.php';

Loop::run(function () {
    try {
        // Instantiate the HTTP client
        $client = new Amp\Artax\DefaultClient;

        // Make an asynchronous HTTP request
        $promise = $client->request('https://httpbin.org/user-agent');

        // Client::request() is asynchronous! It doesn't return a response. Instead, it returns a promise to resolve the
        // response at some point in the future when we've received the headers of the response. Here we use yield which
        // pauses the execution of the current coroutine until the promise resolves. Amp will automatically continue the
        // coroutine then.
        /** @var Response $response */<commit_msg>Allow custom URL in example 1-get-request<commit_after><?php

use Amp\Artax\Response;
use Amp\Loop;

require __DIR__ . '/../vendor/autoload.php';

Loop::run(function () use ($argv) {
    try {
        // Instantiate the HTTP client
        $client = new Amp\Artax\DefaultClient;

        // Make an asynchronous HTTP request
        $promise = $client->request($argv[1] ?? 'https://httpbin.org/user-agent');

        // Client::request() is asynchronous! It doesn't return a response. Instead, it returns a promise to resolve the
        // response at some point in the future when we've received the headers of the response. Here we use yield which
        // pauses the execution of the current coroutine until the promise resolves. Amp will automatically continue the
        // coroutine then.
        /** @var Response $response */
{'fraction_non_alphanumeric': 0.10357583230579531, 'fraction_numerical': 0.0012330456226880395, 'mean_word_length': 2.73963133640553, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5186032', 'n_tokens_mistral': 441, 'n_tokens_neox': 427, 'n_words': 170}