https://github.com/timboudreau/acteur-get-proxy
Demo app which implements a very naive HTTP proxy
https://github.com/timboudreau/acteur-get-proxy
Last synced: 11 months ago
JSON representation
Demo app which implements a very naive HTTP proxy
- Host: GitHub
- URL: https://github.com/timboudreau/acteur-get-proxy
- Owner: timboudreau
- Created: 2015-02-07T04:23:01.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-02-07T05:18:22.000Z (almost 11 years ago)
- Last Synced: 2025-01-10T15:51:14.271Z (12 months ago)
- Language: Java
- Size: 133 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Acteur Get Proxy
================
A demo of how simple it is to write a proxy with [Acteur](https://github.com/timboudreau/acteur) +
[Netty](http://netty.io) and [Netty HTTP Client](https://github.com/timboudreau/netty-http-client), mainly in response to
[this stackoverflow question](https://stackoverflow.com/questions/27923680/asynchronous-http-request-handling-with-tomcat-and-spring).
The entire project consists of three Java source files.
Uses entirely asynchronous I/O to implement a simple HTTP proxy for GET requests, with
a *very* naive cache for responses it's already seen (it's a demo!).
Build
-----
Just check the sources out using Maven, build them and
```
cd target
java -jar acteur-get-proxy.jar
```
Usage
-----
Start the server (by default it runs on port 5957). Access it, passing it the
URL you want it to proxy as the URL parameter `url`. For example, here's
accessing `google.com`:
```
tim@tim ~/ $ curl -i "http://localhost:5957/?url=http://google.com"
HTTP/1.1 301 Moved Permanently
Allow: GET
Content-Length: 219
Location: http://localhost:5957/?url=http://www.google.com/
Content-Type: text/html; charset=UTF-8
Expires: Mon, 09 Mar 2015 04:18:45 GMT
Cache-Control: public, max-age=2592000
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Connection: close
Alternate-Protocol: 80:quic,p=0.02
Server: acteurGetProxy
Date: Sat, 07 Feb 2015 04:17:30 GMT
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 0
301 Moved
301 Moved
The document has moved
here.
```
Note the rewritten `Location` header in the response - a redirect to a remote
server is rewritten as a redirect to the proxy server with the actual redirect
url as a parameter.