After a deep search on the internet I found Smiley's HTTP Proxy Servlet decent to handle proxy request. It is small and composed of a single class. My question is, can I use this proxy as an active proxy, ie. When before fetching the target host, I need to run a piece of code to compute few values. If it is not possible with this servlet, is their any other solution to the problem?
Building an active(smart) proxy
260 Views Asked by aBhijit At
1
There are 1 best solutions below
Related Questions in JAVA
- Add image to JCheckBoxMenuItem
- How to access invisible Unordered List element with Selenium WebDriver using Java
- Inheritance in Java, apparent type vs actual type
- Java catch the ball Game
- Access objects variable & method by name
- GridBagLayout is displaying JTextField and JTextArea as short, vertical lines
- Perform a task each interval
- Compound classes stored in an array are not accessible in selenium java
- How to avoid concurrent access to a resource?
- Why does processing goes slower on implementing try catch block in java?
- Redirect inside java interceptor
- Push toolbar content below statusbar
- Animation in Java on top of JPanel
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- Java Assign a Value to an array cell
Related Questions in SERVLETS
- Redirect inside java interceptor
- Which Should i use for date,time,email in servlet?
- Importing a downloaded JAR file into a Servlet
- Execute RequestDispatcher after 5 seconds
- What's the difference between a ServletHandler and a ServletContextHandler in Jetty?
- How to call servlet file from html
- Requested Resource is not available error
- Struts exclude pattern with spring
- How can I get a custom header from the client in Tomcat?
- How to print Jasper reports from servlets?
- The type javax.servlet.ServletContext and javax.servlet.ServletException cannot be resolved
- ServletContext Attribute : Thread Safety test not working
- Servlet ClassNotFoundException when present in a package ... Why?
- How to create a PDF with iText+XMLWorker from servlet using custom font?
- Starting a ScheduledExecutorService from a servlet with a set of parameters
Related Questions in PROXY
- Bulletproof HTTP Monitor for iOS
- HTTP to HTTPS mapping using proxy servers
- Serving external webpages through a single website
- I dont know how to add Proxy to my Phantomjs script
- How to configure standalone Jetty 9 as a reverse proxy to a node app?
- How to wait inside a method, till other method is completed
- Working on two different Git Organization repos using two different credentials in proxy mode
- How to publish wsdl when using different endpoints in proxy with WSO2?
- npm doesn't download packages (connect ETIMEDOUT)
- Browsersync LiveReload on Proxy Server
- Can the HTTP method "PATCH" be safely used across proxies etc.?
- redirect https to http for content filtering
- Uncaught SoapFault exception: [HTTP] Proxy Authentication Required
- Using phantomjs print proxy it used to access website
- How to set up a reverse proxy in nodejs for multiple targets?
Related Questions in PROXY-CLASSES
- How to Proxy a Promise in JavaScript es6
- Making sure an object will implements an interface
- Entity Framework 6 - Always update properties that were manually setted by code - Change behavior of change tracker in proxy classes
- Proxying or subclassing base classes?
- Using Proxy pattern to write a server a good idea?
- Automated null checks
- How to use automatically generated proxy class?
- Expose type of DLL from web service
- @ControllerAdvice with @Autowired dependency not being injected
- Conditionally calling property/methods on classes
- Can I stop service reference generating ArrayOfString instead of string[]?
- PHP observer pattern / magic setter / proxing
- What is a Proxy in Doctrine 2?
- Passing __call() parameters by reference fails. Any work around?
- Method parameter is missing in WCF proxy class
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Smiley's HTTP Proxy Servlet is described as being easily extendible, because you simply need to extend the class and override the methods you want to modify.
It seems that this proxy can work for your situation, but it depends a little more on your use case. You want to run some code before retrieving the target host, which seems to mean that #1 your target host would be modified based on your custom code, or #2 you simply want a hook to run your custom code before the target host is retrieved. Below are my answers for each:
1) If you want to modify the target host (e.g.
targetUriObjas referenced in the ProxyServlet.java, line 204 of the service() method), you would really need to download the source and modify it directly for your needs. You can either edit the original source, or override theservice()method and change what you need.2) If you simply want your code to run, I would recommend creating an extension of ProxyServlet and override the
service()method, like so: