Comments (5)
The stream handling logic has been implemented as part of the v0.6.0 release, see the changelog for more details: https://github.com/reactphp/http/blob/master/CHANGELOG.md#060-2016-03-09
As such, you're highly recommended to use the latest version of this package.
I hope this helps 👍
from http.
I'm happy to update, but it is impossible because of depending on lot of other libraries.
Is there any way to handle post data in 0.4 version?
from http.
I would suggest making sure everything is compatible with the latest versions and file issues and PRs for all libraries that may not be compatible yet. Updating each library should usually not take more than a few minutes, so I wonder what libraries you're referring to?
Our focus is currently on supporting the latest features in the latest tagged releases, but I suppose we would accept PRs that backport relevant functionality to old release branches as long as BC is preserved 👍
from http.
I have found a workaround that works for me:
$loop = \React\EventLoop\Factory::create();
$socket = new \React\Socket\Server(8080, $loop);
$http = new \React\Http\Server($socket);
$http->on('request', function (\React\Http\Request $request, \React\Http\Response $response) {
if ($request->hasHeader('Content-Length') && $request->getHeader('Content-Length')[0] > 0) {
$request->on('data', function ($data) use ($response) {
echo 'Data'.PHP_EOL;
$response->writeHead(200, array('Content-Type' => 'text/plain'));
$response->end("The length of the submitted request body is: " . serialize($data));
});
} else {
echo 'End'.PHP_EOL;
$response->writeHead(200, array('Content-Type' => 'text/plain'));
$response->end('No data provided');
}
// an error occures e.g. on invalid chunked encoded data or an unexpected 'end' event
$request->on('error', function (\Exception $exception) use ($response, &$contentLength) {
echo 'Error'.PHP_EOL;
$response->writeHead(400, array('Content-Type' => 'text/plain'));
$response->end("An error occured while reading at length: " . $contentLength);
});
});
$loop->run();
At now i have not enough time to pr, but need to make this work very soon) Thanks
from http.
Happy to hear to this works for you 👍 This may or may not work for some smaller request bodies, but will certainly break for larger bodies or using chunked transfer encoding. See also the referenced release notes and all tickets linked to this release to see why we decided to bump the major version here.
from http.
Related Issues (20)
- [Question] How to convert "Psr\Http\Message\StreamInterface" to "React\Stream\ReadableStreamInterface" HOT 1
- HTTP client: streamed request not triggering drain (perhaps) HOT 4
- Preserve method on redirect HOT 1
- Memory leak? HOT 8
- Possible memory leak when using Queue HOT 6
- HTTP client: Expose maximum time to keep alive idle connection with persistent connections HOT 5
- Cannot create socket server HOT 3
- HTTP client on specific network shows poor performance HOT 5
- HTTP client: Simplify HTTP file uploads and submitting forms HOT 1
- EmptyBodyStream as request body not working HOT 3
- Regression: object with __toString no longer being accepted as request body in Browser post HOT 1
- getFragment() returns empty string, username:password@hostname not supported HOT 1
- Unable to properly cancel request (Browser) HOT 8
- URI Behind Reverse Proxy Incorrect Scheme HOT 5
- Laravel + websockets: Unhandled promise rejection with TypeError HOT 1
- MAX_CHUNK_HEADER_SIZE size increase HOT 4
- Random HTTP Requests don't resolve HOT 2
- Body Stream Closes when running Browser Request HOT 3
- The psr/http-message v2 is not supported HOT 1
- Add support for psr/http-message v2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http.