Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Event-driven, streaming HTTP client and server implementation for ReactPHP.

License

NotificationsYou must be signed in to change notification settings

reactphp/http

Repository files navigation

Library for building an evented http server.

This component builds on top of theSocket component to implement HTTP. Hereare the main concepts:

  • Server: Attaches itself to an instance ofReact\Socket\ServerInterface, parses any incoming data as HTTP, emits arequest event for each request.
  • Request: AReadableStream which streams the request body and containsmeta data which was parsed from the request header.
  • Response AWritableStream which streams the response body. You can setthe status code and response headers via thewriteHead() method.

Usage

This is an HTTP server which responds withHello World to every request.

$loop = React\EventLoop\Factory::create();$socket = new React\Socket\Server($loop);$http = new React\Http\Server($socket);$http->on('request', function ($request, $response) {    $response->writeHead(200, array('Content-Type' => 'text/plain'));    $response->end("Hello World!\n");});$socket->listen(1337);$loop->run();

[8]ページ先頭

©2009-2025 Movatter.jp