GithubHelp home page GithubHelp logo

getCode is wrong about reactphp-buzz HOT 3 CLOSED

clue avatar clue commented on July 17, 2024
getCode is wrong

from reactphp-buzz.

Comments (3)

clue avatar clue commented on July 17, 2024

In documentation says to get the status code is getCode() but actually is getStatusCode().

The ResponseInterface defined by PSR-7 provides a getStatusCode() method which should give you access to the HTTP response status code.

Additionally, this library throws a ResponseException by default (see options) if a 4xx or 5xx response status code is encountered. This exception provides a getCode() method as mandated by the underlying exception base class. This method should give you access to the HTTP response status code and is equivalent to calling $exception->getResponse()->getStatusCode().

Edit:
Just tried and if i go with foreach through $urls and then call $client->get(); is not going asynchronous so how to pass links to asnyc loop?

This sounds about right. See also the provided examples in the examples/ folder. Additionally, if you're sending a lot of concurrent requests, you may want to limit this concurrency to a reasonable limit (say no more than a dozen or so at once). See also https://github.com/clue/reactphp-mq.

I hope this helps 👍

I believe this has been answered, so I'm closing this for now. Please come back with more details if this problem persists and we can reopen this 👍

from reactphp-buzz.

mastercho avatar mastercho commented on July 17, 2024

Thanks for the answer.

I actually tried also https://github.com/clue/reactphp-mq but this results in a longer loop than usual foreach.
On tests, if i set 2 queues takes 18 minutes to go through 300 links and normal foreach with curl 6 minutes. Any other suggestions?

from reactphp-buzz.

clue avatar clue commented on July 17, 2024

Ouch, this really shouldn't have happened! I've been using this in a fair number of projects and it's not uncommon to see a 10x improvement when using an appropriate concurrency setting.

Of course it all depends on the particular problem you're trying to solve and also on what the remote end is capable of serving. Can you gist your code so more people can take a look at this? 👍

from reactphp-buzz.

Related Issues (20)

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.