'Creates a new HttpRpcServer.
Args:
host: The host to send requests to.
auth_function: A function that takes no arguments and returns an
(email, password) tuple when called. Will be called if authentication
is required.
user_agent: The user-agent string to send to the server. Specify None to
omit the user-agent header.
source: The source to specify in authentication requests.
host_override: The host header to send to the server (defaults to host).
extra_headers: A dict of extra headers to append to every request. Values
supplied here will override other default headers that are supplied.
save_cookies: If True, save the authentication cookies to local disk.
If False, use an in-memory cookiejar instead.  Subclasses must
implement this functionality.  Defaults to False.
auth_tries: The number of times to attempt auth_function before failing.
account_type: One of GOOGLE, HOSTED_OR_GOOGLE, or None for automatic.
debug_data: Whether debugging output should include data contents.
secure: If the requests sent using Send should be sent over HTTPS.
ignore_certs: If the certificate mismatches should be ignored.
rpc_tries: The number of rpc retries upon http server error (i.e.
Response code >= 500 and < 600) before failing.
options: the command line options (ignored in this implementation).'

def __init__(self, host, auth_function, user_agent, source, host_override=None, extra_headers=None, save_cookies=False, auth_tries=3, account_type=None, debug_data=True, secure=True, ignore_certs=False, rpc_tries=3, options=None):

    if secure:
        self.scheme = 'https'
    else:
        self.scheme = 'http'
    self.ignore_certs = ignore_certs
    self.host = host
    self.host_override = host_override
    self.auth_function = auth_function
    self.source = source
    self.authenticated = False
    self.auth_tries = auth_tries
    self.debug_data = debug_data
    self.rpc_tries = rpc_tries
    self.account_type = account_type
    self.extra_headers = {}
    if user_agent:
        self.extra_headers['User-Agent'] = user_agent
    if extra_headers:
        self.extra_headers.update(extra_headers)
    self.save_cookies = save_cookies
    self.cookie_jar = cookielib.MozillaCookieJar()
    self.opener = self._GetOpener()
    if self.host_override:
        logger.debug('Server:    %s;    Host:    %s', self.host, self.host_override)
    else:
        logger.debug('Server:    %s', self.host)
    if ((self.host_override and (self.host_override == 'localhost')) or (self.host == 'localhost') or self.host.startswith('localhost:')):
        self._DevAppServerAuthenticate()
