Skip to content

Conversation

@luzrain
Copy link
Contributor

@luzrain luzrain commented Jan 26, 2025

Fixed problem:
If you expose ipv6 and try to get access the server using a raw ipv6 address, you will get a 400 error because regexp could not parse ipv6 properly.

Test code to reproduce
Try to get access to http://127.0.0.1:8085 and http://[fe80::215:5dff:fe67:1d75]:8085 (change ipv6 to your local)

use Amp\Http\Server\DefaultErrorHandler;
use Amp\Http\Server\Request;
use Amp\Http\Server\RequestHandler;
use Amp\Http\Server\Response;
use Amp\Http\Server\SocketHttpServer;
use Psr\Log\NullLogger;

$logger = new NullLogger();
$errorHandler = new DefaultErrorHandler();
$requestHandler = new class implements RequestHandler {
    public function handleRequest(Request $request) : Response
    {
        return new Response(body: 'Hello, world!');
    }
};

$server = SocketHttpServer::createForDirectAccess($logger);
$server->expose('0.0.0.0:8085');
$server->expose('[::]:8085');
$server->start($requestHandler, $errorHandler);

// Serve requests until SIGINT or SIGTERM is received by the process.
Amp\trapSignal([SIGINT, SIGTERM]);

$server->stop();

@trowski
Copy link
Member

trowski commented May 18, 2025

Thanks!

@trowski trowski merged commit 7aa962b into amphp:3.x May 18, 2025
6 checks passed
@luzrain luzrain deleted the ipv6_host_parse_fix branch May 19, 2025 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants