Implementing proxy.py in existing code #1148
Replies: 1 comment 2 replies
-
@KeanuNys Welcome to I am not sure why will 2 request need to communicate, pass data or synchronize with each other for your use case. IIUC, you want to perform certain checks by calling pre-written API methods, before processing an incoming request. FWIW, this can be achieved using a simple plugin. Within your plugin's See proxy.py/proxy/http/proxy/plugin.py Lines 108 to 124 in 8922310 I'll not necessarily recommend using core library directly, until we run into a use-case that cannot be solved by Let me know if this helps and how it went. Best |
Beta Was this translation helpful? Give feedback.
-
I am trying to create some sort of a python proxy that has the following functionality:
As you can see these are a lot of different parts. I'm not very experienced with python and only use it from time to time for simple actions, but I'm doing this little project just to learn from it (so any tips are welcome).
I've looked at some of the default plugins, as well as at some of the library examples, however, I'm having a hard time getting started.
I'm fairly sure most of the functionality can be implemented as a custom plugin, but I don't think that would be the best approach in my scenario? Doing everything in one or multiple plugins would make it harder for the different pieces to communicate with each other as far as I understand. For instance, the arbitrary HTTP requests that would need to be sent out in certain scenarios would be one of about 20 ~ 50 predefined API calls that I would need to implement in python as functions as well. (e.g.
get_something_api_1(arg1, arg2)
,set_something_api_1(arg1, arg2, arg3, arg4)
, ...)Therefore I thought I might need more of a library approach such as in these examples instead of using plugins.
I started this project a while back by implementing some sort of communicator class using python http.client and I already have multiple functions implemented in that class to send specific API calls. So if I want to use that functionality, I just need to create an instance of the communicator class and call the function with the specific arguments.
Now I realize that I might benefit from being able to send those API calls when specific requests from the browser are sent, requiring a proxy to monitor the traffic. This is how I came to this awesome project. But I'm having a hard time trying to integrate it into my existing code.
I also realize that this will require implementing some multithreading or multiprocessing in order to not block the browser while doing some actions. I'm fairly new to that as well.
Beta Was this translation helpful? Give feedback.
All reactions