Properly treat content-type header

If content-type is specified as application/json, treat request data as JSON rather than a query string.