Allow HttpResponse objects to be returned from ajax functions

Allowing HttpResponse objects allows ajax functions (or decorators)
to implement better error handling (such as a 401 for Unauthorized),
which follows the HTTP specification more closely. Make sure that
the proper response codes are being returned for error conditions.