php-http / socket-client Goto Github PK
View Code? Open in Web Editor NEWSocket HTTP Client
Home Page: http://httplug.io
License: MIT License
Socket HTTP Client
Home Page: http://httplug.io
License: MIT License
All the examples in test
are only for GET method. When I tried doing a POST request without any data it succeeded, but if I add data in form of String or PHP array, it throws a NetworkException exception saying, 'Cannot read the response'
Actually the root namespace is Http\Socket
Should this be renamed to Http\Client\Socket
?
Also SocketHttpClient can be renamed to SocketClient ?
apologies, i was looking at releases wrong.
Fatal Compile Error: Declaration of Http\Client\Socket\Stream::close()
must be compatible with Psr\Http\Message\StreamInterface::close(): void
$ composer show php-http/socket-client | grep version
versions : * 2.1.1
$ composer show psr/http-message | grep version
versions : * 2.0
Hello,
I tried to use the socket-client
to upload some data on a server. I've a basic implementation which create a client and inside a foreach loop, I make the upload requests using the Guzzle PSR7 message factory.
foreach ($iterator as $splfileinfo) {
$response = $this->httpClient()->sendRequest(
$request = $this->requestFactory()->createRequest(
'POST',
$sendUrl,
$headers,
$splFileInfo->openFile('r')
)
);
}
After 1007 successful requests, I got the Too many open files
error and it seems that's the number of opened socket by the client. Is it normal that the socket connexion is never closed after the request is successfully sent (maybe I miss something ๐) ?
From @shaneiseminger
Method Http\Client\Socket\Stream::__toString() must not throw an exception
When using this library with happyr/linkedin-api-client, I'm getting the above fatal error. Just needs a try/catch block in __toString(). Happy to submit a pull request.
(Originally posted here: php-http/documentation#135)
I believe there is now enough support in php and libraries to do that "easily"
Biggest problem is on the API, as a request can receive multiple reponses, it will certainly need a decorator around a PSR7 Response (A specific stream implementation) / decorator)
Apart from some dependencies issues, the socket client is nearly done (we can always add thing, but it is ok for a first version IMO)
It's available here: https://github.com/joelwurtz/socket-adapter-temp
How do you want to proceed for review ? merging it here ?
It is possible to init the repository so i can work on a fork ?
I have already do some stuff here : https://github.com/joelwurtz/socket-adapter-temp but would be better for review if we have a WIP PR
Edit : Nevermind this issue, i didn't see the response on the other project ^^ (damn you browser cache ^^)
Description
PSR-18 support has been added two years ago in #38, but there is no tag for version 2.0.0 (stable) - only for 2.0.0-beta1
It would be nice if the package got an official stable 2.0.0 release with PSR-18 support.
The master build is currently broken.
https://travis-ci.org/php-http/socket-client/builds/153827605
Eventually (when the current docs is updated with httplug content) documentation should go right into the official docs.
This will drop PHP5 and force us to release a new major version.
Have the same thing as the Guzzle5 Adapter
NetworkException is used in many places without any specific exception codes. This leaves downstream user code that handles the exceptions in a position where they are must do exception message parsing if they want granular exception handling. These exceptions should have codes or even better be named exceptions that extend NetworkException.
This is not really an adapter, but a client.
WDYT @joelwurtz ?
When I call Http\Client\Socket\Stream::read($length) method with a $length
value greater than the stream size, an StreamException is thrown with the message "Cannot read more than %s"(also a sprintf call is missed here).
But the StreamInterface::read documentation describes that it can returns fewer than $length
bytes, so the Http\Client\Socket\Stream::read must return the remaining stream content up to $length
bytes instead of throwing an exception.
PHP version: 8.0+
Description
This library requires symfony/options-resolver on version 5.* or below, but Symfony 6.0 has been released 1 month ago.
How to reproduce
Use this library with a project build on Symfony 6.0
Possible Solution
Update composer.json to support also symfony/options-resolver
with the version 6.0
This commit have been broken behavior when request timeout exceeded. When this code evaluated, we'll get fatal/throwable error like this:
Wrong parameters for Http\Client\Socket\Exception\TimeoutException([string $message [, long $code [, Throwable $previous = NULL]]]) (uncaught exception) at /vendor/php-http/socket-client/src/ResponseReader.php line 51 while running console command
#0 /vendor/php-http/socket-client/src/ResponseReader.php(51): Exception->__construct('Error while rea...', Object(GuzzleHttp\Psr7\Request))
This error happens cause current TimeoutException
extendw default php \RuntimeException
, although previous NetworkException
use RuntimeException
, which has different controller and arguments (second argument is request object)
Wrong parameters for Http\Client\Socket\Exception\TimeoutException([string $message [, long $code [, Throwable $previous = NULL]]])" {"exception":"[object] (Error(code: 0): Wrong parameters for Http\\Client\\Socket\\Exception\\TimeoutException([string $message [, long $code [, Throwable $previous = NULL]]]) at php-http/socket-client/src/ResponseReader.php:51
I found a problem in the 2nd parameter for thrown exception. There passing RequestInterface object and not exception code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.