Comments (6)
Sorry, I didn't mean to say in a negative way against the PSR-18 itself, I completely respect the work that was done.
I just meant that the prevention for my problem's solution is the way that the PSR-18 was designed.
It would be nice if straight from a PSR18 client we would have the ability to tell if it should follow or not redirects, as other configurations like to set a proxy or set the timeout.
from guzzle6-adapter.
@ricardofiorani There is a redirect plugin. I think that should be of interest for you.
from guzzle6-adapter.
That is exactly what I needed!
Thank you @xabbuh! 🙇
from guzzle6-adapter.
this is the expected behaviour according to the specification: https://www.php-fig.org/psr/psr-18/meta/#middleware-and-wrapping-a-client
all psr http clients are expected to behave the same way by default.
depending on what you do, you want to explicitly know about redirections. when building an api client, you probably want exceptions in all but the production environment to realize you are being inefficient, etc.
if it makes sense to have redirections in your project, you have 2 options:
- you can decorate any psr client with a plugin client and use the php-http redirect plugin
- you can instantiate the guzzle client yourself and pass it to the guzzle6-adapter:
$adapter = new GuzzleAdapter($guzzle);
(afaik the default guzzle also throws exceptions on 4xx/5xx responses, which PSR is supposed to also not do)
from guzzle6-adapter.
Oh, I didn't know the problem was deep down on PSR-18 specification itself.
I mean, I'm assuming people want to have the functionality of following redirects as it makes everything easier instead of tumbling another problem on the PSR level. So I just question myself why was it done this way.
Anyway thank you for your help @dbu, I really appreciate it!
from guzzle6-adapter.
Anyway thank you for your help @dbu, I really appreciate it!
glad i could help 👍
Oh, I didn't know the problem was deep down on PSR-18 specification itself.
i don't think its a problem or a mistake of the PSR. it depends on the use case, redirection does not make sense for everyone. the PSR had to chose one way to guarantee a consistent experience over all clients. adding redirection handling is doable in such a scanner - removing it by wrapping the client somehow is impossible.
if you build an api client and don't notice that every single request you do is redirected, the efficiency penalty is massive, so you really want to know about that.
if you build a library to scan some site and want to explicitly know about redirects, you really need a client that does not follow redirects itself.
from guzzle6-adapter.
Related Issues (20)
- Request for 1.2.0 stable HOT 2
- Imposible to post via adapter HOT 2
- Exceptions thrown in chained promises are wrapped HOT 4
- Promise\settle() is not working properly HOT 8
- PHP increase breaks existing composer installs HOT 4
- Release 1.2.0 HOT 2
- Use the official PSR-18 package HOT 1
- Non PSR-18 exceptions HOT 14
- Composer Installation Failed HOT 6
- Guzzle 7 support HOT 3
- production.ERROR: Interface 'Http\Client\HttpClient' not found HOT 7
- Updating for PHP 8.0 HOT 2
- Support for PHP8 HOT 1
- Support PHP 8.0
- PHP 8 support HOT 6
- Another case for allowing PHP 8 in composer.json HOT 4
- Upgrade the guzzlehttp version to maximum. HOT 2
- Make an empty v3 version for guzzle7 compat HOT 3
- Can not update some packages, because this package requires guzzlehttp/guzzle ^6.0 and not ^7.0 HOT 2
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 guzzle6-adapter.