Quick refactor of the http logic in ForeignAPIRepo

Automatic caching, will enable slightly smaller patches elsewhere.

Resetting after failing at a rebase.

Change-Id: I6849107a3af773687a31155b23a2d7b4d7a60645