anyproxy | A fully configurable http/https proxy in NodeJS | HTTP library
kandi X-RAY | anyproxy Summary
kandi X-RAY | anyproxy Summary
AnyProxy is A fully configurable HTTP/HTTPS proxy in NodeJS. Home page : AnyProxy.io. Legacy doc of version 3.x :
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- returns a function that can use req . req
- returns a connect handler for the given host
- Create a websocket handler .
- Fetch a remote response from a stream
- Switches action reducer to redis and redis active state .
- Initialize a new SNI server .
- Prints the log to the given type
- Initialize the search widget
- Merge the input data with a config file
- normalize request object
anyproxy Key Features
anyproxy Examples and Code Snippets
Community Discussions
Trending Discussions on anyproxy
QUESTION
I'm working on a proxy that caches files and I'm trying to add some logic that prevents multiple clients from downloading the same files before the proxy has a chance to cache them.
Basically, the logic I'm trying to implement is the following:
Client 1 requests a file. The proxy checks if the file is cached. If it's not, it requests it from the server, caches it, then sends it to the client.
Client 2 requests the same file after client 1 requested it, but before the proxy has a chance to cache it. So the proxy will tell client 2 to wait a few seconds because there is already a download in progress.
A better approach would probably be to give client 2 a "try again later" message, but let's just say that's currently not an option.
I'm using Nodejs with the anyproxy library. According to the documentation, delayed responses are possible by using promises.
However, I don't really see a way to achieve what I want using Promises. From what I can tell, I could do something like this:
...ANSWER
Answered 2020-May-27 at 00:43You can use a Map
to cache your file downloads.
The mapping in Map
would be url
-> Promise { file }
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install anyproxy
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page