leedo/Plack-App-Proxy — pull request #11 by dex4er (2014-01-24 21:42:27+00:00)
Title: Feature/no lwp depends

Hello,

It would be great if Plack::App::Proxy doesn't use LWP::UserAgent but Plack::LWPish. Making LWP as optional module will make that only pure Perl modules are required and none of XS modules at all. It will make easier to install this great module on platforms without compiler.

Unfortunately, HTTP::Tiny (via Plack::LWPish) is strictly HTTP 1.1 compatible and doesn't allow to use custom Host header. Fortunately, we can override some of its method and preserve this header. See https://github.com/chansen/p5-http-tiny/pull/34 for explanation.

I've tested the Plack::App::Proxy with this patch on Android and it works really great! It allows to use the mobile as a HTTP proxy server:

```
dexter@hp-probook-6460b:~$ ssh htc-one-s -p22022
dexter@htc-one-s's password:
cctools@localhost:/data/data/com.pdaxrom.cctools/root/cctools/home # uname -a
Linux localhost 3.4.61-LIBERTY-SENSE-v4-g291f820-dirty #1 SMP PREEMPT Thu Sep 12 14:36:20 EAT 2013 armv7l GNU/Linux
cctools@localhost:/data/data/com.pdaxrom.cctools/root/cctools/home # twiggy -MPlack::App::Proxy \
> -e 'enable q{AccessLog}; enable q{Proxy::Connect}; \
> enable q{Proxy::AddVia}; enable q{Proxy::Requests}; \
> Plack::App::Proxy->new->to_app'
192.168.1.74 - - [24/Jan/2014:21:38:31 +0000] "HEAD http://www.cpan.org/ HTTP/1.0" 200 - "-" "-"
```

```
dexter@hp-probook-6460b:~$ telnet htc-one-s 5000
Trying 192.168.1.84...
Connected to htc-one-s.
Escape character is '^]'.
HEAD http://www.cpan.org/ HTTP/1.0

HTTP/1.0 200 OK
Date: Fri, 24 Jan 2014 21:31:59 GMT
Via: 1.1 varnish
Age: 114
ETag: "76ca00-1f76-4f0bdb9a62040"
Server: Apache/2.2.3 (CentOS)
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
Last-Modified: Fri, 24 Jan 2014 21:06:01 GMT
X-Cache: HIT
X-Cache-Hits: 7
X-Served-By: eu3.develooper.com
X-Varnish: 1963777543 1963777251

Connection closed by foreign host.
```