This fixes the exception:
TypeError: %b requires a bytes-like object, or an object that implements __bytes__, not 'str'
On the line:
ui.debug('Content-Type: %s\n' % content_type)
And it prevents additional exceptions that use the content_type
variable later.