Comments (13)
I moved the questioned code parts into own classes (filters), so its configurable/enableable by the user now ;) rebuy-de/php-proxy#1
To use that new feature you would have to accept my PR #11 which includes a few BC-Breaks
from php-proxy.
The location rewrite is to prevent the user to be redirected to a different url immediately. Somethings it makes the user follow redirects in a loop, in other situations it can be helpful.
The transfer-encoding and content-encoding are removed so that the own webserver can set the correct headers if it uses a different encoding method.
from php-proxy.
I think it would be interesting to create some sort of Proxy\Transport interface/abstract class that handles the conversion of the Symfony request object to the actual Guzzle objects. For Guzzle there would then be a Proxy\GuzzleTransport class.
from php-proxy.
The location rewrite is to prevent the user to be redirected to a different url immediately. Somethings it makes the user follow redirects in a loop, in other situations it can be helpful.
Ah i see, wouldnt it be better then to remove the location header and add is as a X-PHPProxy-Location
Header?
The transfer-encoding and content-encoding are removed so that the own webserver can set the correct headers if it uses a different encoding method.
Okay, works for me.
I think it would be interesting to create some sort of Proxy\Transport interface/abstract class that handles the conversion of the Symfony request object to the actual Guzzle objects. For Guzzle there would then be a Proxy\GuzzleTransport class.
Basically thats exactly what i created with my converters in the referenced rebuy-de/php-proxy#1 PR
Btw. under which license is phpproxy published?
from php-proxy.
I quickly released this version because I wanted to integrate Symfony request and response objects. I will be making changes as soon as I can find some spare time.
All my packages are MIT.
from php-proxy.
Hehe, how big are the chances you would merge the #11 PR? :)
from php-proxy.
Your PR has some great additions, but there are some things I would change though. Instead of the RequestConverterInterface, I would use "transporters" (or whatever) that receive a Symfony Request, do the actual http request and return a Symfony Response. I really like your filters. And I don't know about the namespace, wouldn't Proxy\Factory look nicer than Phpproxy\Factory?
from php-proxy.
I would use "transporters" or whatever that receive a Symfony Request and return a Symfony Response.
Is the Converters vs Transportes just a naming issue? Or does symfony have a transporter module?
And I don't know about the namespace, wouldn't Proxy\Factory look nicer than Phpproxy\Factory?
Sure i am totally fine and agree with that. The namespace is based on the repository name ;). Or we could call it Phproxy :P
from php-proxy.
Transporters, clients, ... I don't know what the best name would be. It would work like this: when you construct a Proxy object, you inject a Transporter/Client instance using the constructor. The Proxy object is requested to forward a Symfony request to a certain url and after doing some filters, it passed the Request to the transporter/client which will return a Symfony Response. This way, the transporter will take care of converting the Request to something that it can use.
This way you would be able to do stuff like this:
$proxy = new Proxy(new GuzzleTansporter);
Or a:
$proxy = new Proxy(new DummyTransporter);
Or a:
$proxy = new Proxy(new CurlTransporter);
from php-proxy.
Great idea! I'll try to implement that :)
from php-proxy.
And the included Factory can just create a Proxy instance with a default GuzzleClient/GuzzleTransporter.
from php-proxy.
Here we go, the PR now includes Adapters (aka Transports) and the updated namespace.
On second thought one could simply change the Adapter that guzzle uses, but the change makes the code more readable.
from php-proxy.
Btw, i will close this issue now. We should continue our discussion in the #11 PR.
I am keen to read your feedback.
from php-proxy.
Related Issues (20)
- Class ServerRequestFactory not found HOT 5
- Problems with POST and forms HOT 4
- stress test exception!!
- Fatal error: Uncaught Error: Class 'Zend\Diactoros\Response\SapiEmitter' not found HOT 1
- Port gets lost on forwarded webpage.
- Zend\Diactoros\Response\SapiEmitter has been depricated HOT 4
- How can I send basic authentication with request? HOT 1
- HTTP ERROR 500 HOT 1
- Here's an alternative for Laravel 7, or PHP only:
- upload file proxy invalid HOT 2
- Need example how to change response body HOT 1
- Doesn't work with Laravel 8 HOT 3
- .
- EmitterException: Output has been emitted previously HOT 1
- Response of url to a varible
- POST form_params is not passed down/proxied at all
- Skip Ajax Requests
- Urls not redirected.
- How to forward to different Port?
- Failed opening required 'vendor/autoload.php'
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 php-proxy.