Thursday, April 4, 2013

Let Charles help you monitor HTTP requests


You often need to monitor HTTP requests, be it from your browser to the server, or from the server to backend services. You can setup Orbeon Forms to log the body of Ajax requests and responses, as well as the body of requests and responses Orbeon Forms makes to backend services. All that information goes into a log file, in which it is sometimes hard to quickly find what you're looking for, and a software specifically designed to help you monitor HTTP requests can often show this information in a better way.

For this, until recently, I've been recommending (and myself using) the OS X app HTTP Scoop. If not on OS X, I pointed folks to WireShark, which is extremely powerful, but also rather hard to use. I recently discovered Charles, have been using it full time for the last week, and now wholeheartedly recommend it. It is simple to use, like HTTP Scoop, but runs on Windows and Linux, and provides lots of additional features. You can download a 30-day trial, and it costs $50 after that.

Unlike HTTP Scoop or WireShark, Charles works as a proxy; this means that apps need to be configured to go through that proxy instead of connecting directly to the server. On OS X and Windows, Charles registers itself as a proxy with the system, and so requests from browsers that honor that system configuration will automatically go through Charles, which is the case with Chrome, Safari, and IE. Firefox doesn't use the proxy setup done at the system level, but Charles comes with a Firefox add-on which makes this setup for you.

Next, so Charles can also intercept HTTP requests made by Orbeon Forms, typically to backend services, you'll want to add the following two properties to your properties-local.xml.
<property as="xs:string"  name="oxf.http.proxy.host" value="localhost"/>
<property as="xs:integer" name="oxf.http.proxy.port" value="8888"/>
As a side-note, Charles is developed by Karl von Randow, who also develops Camera+, my favorite iPhone app, which I pitched to many people as what Apple's built-in Camera app should have been.

No comments:

Post a Comment