Giter Site home page Giter Site logo

Feature request: proxy about phrets HOT 6 CLOSED

troydavisson avatar troydavisson commented on August 16, 2024
Feature request: proxy

from phrets.

Comments (6)

sylnsr avatar sylnsr commented on August 16, 2024

Good question. I'm looking at similarly facing these issues as we grow and need to be able to shift ETL processes to different colos as needed. Out of curiosity, and assuming that that your provider in question does not use HTTPS anywhere, could you setup your proxy server to rewrite incoming HTTP responses so that it can be used to rewrite the addresses in the headers of HTTP redirects? In other words (depending on your proxy software) you could have it rewrite http://retssystem.com/XYZ to http://retsproxy.myserver.com/XYZ for you.

from phrets.

troydavisson avatar troydavisson commented on August 16, 2024

Yeah, it can be done.

To make sure I totally understand what you're after, will the following work:

  1. Provide a $rets->overrideHostWith() method which allows you to pass in an alternate hostname
  2. Any request (including the original Login) that references the real server would have it's hostname swapped with whatever the override is to instead send the request through the proxy
  3. PHRETS does this right before cURL calls are invoked so anything RETS specific is overridden
  4. No support or warranty as to the stability or working nature of this code and/or the proxy setup is provided

from phrets.

sylnsr avatar sylnsr commented on August 16, 2024

Ideally it should be able to allow for regex match and replace.

from phrets.

troydavisson avatar troydavisson commented on August 16, 2024

Ok. To anyone reading this now or in the future, using this feature without a complete understanding of what you're doing is NOT recommended.

I've pushed a commit (e8ffc8d) to the "proxy" branch which adds this. The new method accepts a callback as the only parameter. So after you instantiate your PHRETS object, do:

$rets->rewriteRequestURL(function ($url) {
     // take $url and do something crazy to it
     return $url;
});

from phrets.

troydavisson avatar troydavisson commented on August 16, 2024

(Submitted prematurely)

That function, if defined, will be called before every request is made by PHRETS. $url represents what it is about to use giving you a chance to do a regex replace or whatever before it fires. Whatever returns from that closure will be used as the URL.

from phrets.

tylercollier avatar tylercollier commented on August 16, 2024

Thanks @troydavisson. It works as expected. Allowing me to provide a function to manipulate the URL was smarter than my original suggestion of just allowing me to replace the domain, because I also need to change the port.

For anyone reading this, manipulating the URL was a real pain since I can't guarantee the systems running my code will have PECL, so I can't use its library for its convenient http_build_url method. Instead I found this roll-your-own version.

from phrets.

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.