def _add_transport_headers(headers):
    """
    Adds the transport framing headers, if needed. Naturally, this method
    cannot add a content-length header, so if there is no content-length header
    then it will add Transfer-Encoding: chunked instead. Should only be called
    if there is a body to upload.

    This should be a bit smarter: in particular, it should allow for bad or
    unexpected versions of these headers, particularly transfer-encoding.
    """
    transfer_headers = 'content-length', 'transfer-encoding'
    for header_name in headers:
        if header_name.lower() in transfer_headers:
            return
    headers['transfer-encoding'] = 'chunked'
