def encode_pair(name, value):
    """
    Encodes a name/value pair.

    The encoded string is returned.
    """
    nameLength = len(name)
    if nameLength < 128:
        s = chr(nameLength).encode()
    else:
        s = struct.pack('!L', nameLength | 0x80000000)

    valueLength = len(value)
    if valueLength < 128:
        s += chr(valueLength).encode()
    else:
        s += struct.pack('!L', valueLength | 0x80000000)

    return s + name + value

    Encodes a name/value pair.

    The encoded string is returned.
    
web/utils/php/fcgi_client.py