def encode_headers(headers):
    """Encodes HTTP headers.

    Args:
        headers: Dictionary of HTTP headers.

    Returns:
        String containing encoded HTTP headers.
    """
    return '\n'.join(["%s: %s"%(k,headers[k]) for k in sorted(headers.keys())])