mattsven
mattsven

Reputation: 23253

How can I locally intercept and respond to browser requests?

I want to set something up on my computer where if something (program, browser, whatever) makes a request (to a certain domain, I guess) I can send my own response to the request. I once saw a program that did that, and I was wondering how it did it. How would it be done?

Upvotes: 3

Views: 1397

Answers (3)

Frank Shearar
Frank Shearar

Reputation: 17132

What mikerobi said, but you can also set up your computer or gateway machine to act as a transparent proxy. (You need this if you either don't want to configure your browser, or you're working with an application that uses HTTP but doesn't allow for configuration of a proxy.)

On a FreeBSD or Linux machine (I'm sure there are other OSes that can do this; I mention the ones I use), you can set up your own firewall rules to intercept particular traffic (say, all port 80 traffic, or all port 80 traffic to a particular domain, or whatever) and forward the traffic to your own special proxy, which can return whatever you want.

Upvotes: 1

AndrejaKo
AndrejaKo

Reputation: 1749

How about just editing hosts file? Popular operating systems have it. Just use it to redirect to whereever you want. To me it looks like the simplest solution to this question.

Upvotes: 3

mikerobi
mikerobi

Reputation: 20878

You can build a HTTP proxy that will intercept all requests from the browser. But you have to configure the browser to use the proxy.

Upvotes: 1

Related Questions