[Reviewer: Mike] Fix AS handling when request URI is external

Mike,

Please can you review my fix to #519?  This actually turned out to be because we didn't apply IFC processing if the request URI was external.  I've fixed this and added live tests for

*   a terminating AS diverting to an external URI (which is what exposed the original issue)
*   an originating AS diverting to an external URI
*   a terminating AS diverting to an external URI and then an originating-cdiv AS diverting to a different external URI.

Note that there is some tidy-up to do in `stateful_proxy.cpp` - there's a nested conditional block that can be flattened.  I didn't do this in this pull request because it would have made code review a pain, but I'll do that once this is committed.

Matt