404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.145.39.183: ~ $
<?php

namespace GuzzleHttp\Tests;

use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\MessageFormatter;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\TestCase;

/**
 * @covers \GuzzleHttp\MessageFormatter
 */
class MessageFormatterTest extends TestCase
{
    public function testCreatesWithClfByDefault()
    {
        $f = new MessageFormatter();
        self::assertEquals(MessageFormatter::CLF, Helpers::readObjectAttribute($f, 'template'));
        $f = new MessageFormatter(null);
        self::assertEquals(MessageFormatter::CLF, Helpers::readObjectAttribute($f, 'template'));
    }

    public function dateProvider()
    {
        return [
            ['{ts}', '/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}/'],
            ['{date_iso_8601}', '/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}/'],
            ['{date_common_log}', '/^\d\d\/[A-Z][a-z]{2}\/[0-9]{4}/']
        ];
    }

    /**
     * @dataProvider dateProvider
     */
    public function testFormatsTimestamps(string $format, string $pattern)
    {
        $f = new MessageFormatter($format);
        $request = new Request('GET', '/');
        $result = $f->format($request);
        if (method_exists($this, 'assertMatchesRegularExpression')) {
            // PHPUnit 9
            self::assertMatchesRegularExpression($pattern, $result);
        } else {
            // PHPUnit 8
            self::assertRegExp($pattern, $result);
        }
    }

    public function formatProvider()
    {
        $request = new Request('PUT', '/', ['x-test' => 'abc'], Psr7\Utils::streamFor('foo'));
        $response = new Response(200, ['X-Baz' => 'Bar'], Psr7\Utils::streamFor('baz'));
        $err = new RequestException('Test', $request, $response);

        return [
            ['{request}', [$request], Psr7\Message::toString($request)],
            ['{response}', [$request, $response], Psr7\Message::toString($response)],
            ['{request} {response}', [$request, $response], Psr7\Message::toString($request) . ' ' . Psr7\Message::toString($response)],
            // Empty response yields no value
            ['{request} {response}', [$request], Psr7\Message::toString($request) . ' '],
            ['{req_headers}', [$request], "PUT / HTTP/1.1\r\nx-test: abc"],
            ['{res_headers}', [$request, $response], "HTTP/1.1 200 OK\r\nX-Baz: Bar"],
            ['{res_headers}', [$request], 'NULL'],
            ['{req_body}', [$request], 'foo'],
            ['{res_body}', [$request, $response], 'baz'],
            ['{res_body}', [$request], 'NULL'],
            ['{method}', [$request], $request->getMethod()],
            ['{url}', [$request], $request->getUri()],
            ['{target}', [$request], $request->getRequestTarget()],
            ['{req_version}', [$request], $request->getProtocolVersion()],
            ['{res_version}', [$request, $response], $response->getProtocolVersion()],
            ['{res_version}', [$request], 'NULL'],
            ['{host}', [$request], $request->getHeaderLine('Host')],
            ['{hostname}', [$request, $response], \gethostname()],
            ['{hostname}{hostname}', [$request, $response], \gethostname() . \gethostname()],
            ['{code}', [$request, $response], $response->getStatusCode()],
            ['{code}', [$request], 'NULL'],
            ['{phrase}', [$request, $response], $response->getReasonPhrase()],
            ['{phrase}', [$request], 'NULL'],
            ['{error}', [$request, $response, $err], 'Test'],
            ['{error}', [$request], 'NULL'],
            ['{req_header_x-test}', [$request], 'abc'],
            ['{req_header_x-not}', [$request], ''],
            ['{res_header_X-Baz}', [$request, $response], 'Bar'],
            ['{res_header_x-not}', [$request, $response], ''],
            ['{res_header_X-Baz}', [$request], 'NULL'],
        ];
    }

    /**
     * @dataProvider formatProvider
     */
    public function testFormatsMessages(string $template, array $args, $result)
    {
        $f = new MessageFormatter($template);
        self::assertSame((string) $result, $f->format(...$args));
    }
}

Filemanager

Name Type Size Permission Actions
Cookie Folder 0755
Exception Folder 0755
Handler Folder 0755
ClientTest.php File 30.54 KB 0644
HandlerStackTest.php File 7.44 KB 0644
Helpers.php File 975 B 0644
HttplugIntegrationTest.php File 369 B 0644
InternalUtilsTest.php File 569 B 0644
MessageFormatterTest.php File 4.12 KB 0644
MiddlewareTest.php File 9.87 KB 0644
PoolTest.php File 6.41 KB 0644
PrepareBodyMiddlewareTest.php File 5.34 KB 0644
RedirectMiddlewareTest.php File 20.44 KB 0644
RetryMiddlewareTest.php File 3 KB 0644
Server.php File 6.12 KB 0644
TestLogger.php File 2.8 KB 0644
TransferStatsTest.php File 995 B 0644
UtilsTest.php File 5.48 KB 0644
bootstrap-phpstan.php File 173 B 0644
bootstrap.php File 1.05 KB 0644
server.js File 8.1 KB 0644