mitmproxy/mitmproxy — pull request #189 by mhils (2013-12-10 01:52:24+00:00)
Title: Refactor ProxyHandler

This PR refactors `ProxyHandler.read_request` and its submethods to remove duplicate code and clearly separate request processing. As this is pretty much the core of mitmproxy, I'd love to have a second opinion on it. The github diff is pretty much useless, reading the [new proxy.py lines 337-450](https://github.com/mitmproxy/mitmproxy/blob/refactor_proxyhandler/libmproxy/proxy.py#L337) gives a better picture of the changes ([old proxy.py here](https://github.com/mitmproxy/mitmproxy/blob/master/libmproxy/proxy.py#L337)). If there are no objections, please merge.

By the way, this restructuring unfolded a few caveats, namely processing [absolute-form request targets](https://svn.tools.ietf.org/svn/wg/httpbis/draft-ietf-httpbis/latest/p1-messaging.html#request-target) in reverse proxy or transparent mode. mitmproxy fails to do that correctly at the moment. In other words, this breaks a `client -> transparent mitmproxy -> other proxy -> destination` setup. However, that is a separate issue not introduced by these changes.

Cheers,
Max