Send an error when an error occurs in json.dumps

For example, UnicodeDecodeError could be raised by json.dumps.
HTTP: Add port number to the url
HTTP: Fix path resolution