GithubHelp home page GithubHelp logo

socket-client's Issues

Root Namespace

Actually the root namespace is Http\Socket

Should this be renamed to Http\Client\Socket ?
Also SocketHttpClient can be renamed to SocketClient ?

How to do a POST request using this socket-client library ?

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'

"Too many open files" error triggered after sending 1000 requests.

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 ๐Ÿ˜„) ?

HTTP2 Support

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)

Tag version 2.0.0

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.

Incorrect 2nd parameter for exceptions

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.

Invalid StreamInterface::read implementation

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.

Timeout exceeded cause php fatal/throwable error

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)

NetworkException usage is too ambiguous

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.

Add PHP 8 support

Description
PHP 8.0.0 has been launched for a month already, PHP 8.0.1-RC1 is already tagged and the library still does not support it.

Example
It is not really a feature by itself, but it's about supporting the latest language version.

Additional context
I'm working on a PR for this :)

Not installable with a Symfony 6 project

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

Support PSR-18

This will drop PHP5 and force us to release a new major version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.