 					filter endpoint
 
 				# Process HTTP request through authentication scheme.
-				@processRequest method, endpoint.toString(), mime, body, (err, data, res) ->
+				@processRequest method, endpoint.toString(), mime, body, (err, data, res) =>
 					# User callbacks.
 					return unless cb
 					if err
 						cb(err, null, null)
 					else
-						media = new HyperMedia res, data
+						media = new HyperMedia res, @format, data
 						cb media.errorCode, media.data, media
 
 	processRequest: (method, endpointUrl, mime, body, cb) ->

		endpoint.query.Timestamp = new Date().toJSON()
		# Create a signature of query arguments.
		# TODO(tcr) also post arguments...
		hash = crypto.createHmac 'sha256', @api.opts.secret
		hash.update [
			# Method
			"GET"

# Parsed hypermedia response and helper methods.

class HyperMedia
	constructor: (@res, @type, @text) ->
		@statusCode = Number(@res.statusCode)
		@errorCode = if @statusCode > 400 then @statusCode else 0
		
		# Parse body
		try
			if @type == 'xml'
				@data = @xml = (libxmljs ?= require('libxmljs')).parseXmlString @text
			else
				@data = @json = JSON.parse @text
		catch e

