WorkShop n°20 : Emulate the iPhone User-Agent with a hook
In this workshop, we demonstrate how the iPhone User-Agent can be emulated using a synchronous Hook.
This can be useful when testing an iPhone compatible web site.
- The Hook can be built with few clicks using the "Hook Builder" accessible from the Settings panel
- We just need to remove the User-Agent HTTP header and insert the iphone's one, then press 'Apply' and check the option 'Apply an automatic transformation to packets' back on the Settings panel
- Now you can check that this is working visiting web sites that serve a dedicated content for the iPhone (for instance here www.google.com)
- Now, let's see how the very same hook can be implemented with your own java class plugin
- Create a java project and import the TcpCatcher jar into it. Then, write a class that implements the tcpcatcher.CustomHook interface and that may look like this one
(Notice that your class must not belong to any package in order to be loaded at runtime.)
- TcpCatcher provides an API to remove or insert HTTP headers, but you can also perform your own programmatic modifications on the TcpCatcherPacket.packetbytes array..
- Now, engage the synchronous hook from the Settings panel and apply settings. You should be getting the same results.