An open API service indexing awesome lists of open source software.

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

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.