'Resolve the values of the target parameter and the `Host\' header.
Requires that the attributes __target and __headers exist before this method
is called.
This function should only be called once from the __init__ function of the
Task class.
Raises:
InvalidTaskError: If the task is invalid.'

def __resolve_hostname_and_target(self):

    if ('HTTP_HOST' not in os.environ):
        logging.warning("The    HTTP_HOST    environment    variable    was    not    set,    but    is    required    to    determine    the    correct    value    for    the    `Task.target'    property.    Please    update    your    unit    tests    to    specify    a    correct    value    for    this    environment    variable.")
    if ((self.__target is not None) and ('Host' in self.__headers)):
        raise InvalidTaskError('A    host    header    may    not    be    set    when    a    target    is    specified.')
    elif (self.__target is not None):
        host = self.__host_from_target(self.__target)
        if host:
            self.__headers['Host'] = host
    elif ('Host' in self.__headers):
        self.__target = self.__target_from_host(self.__headers['Host'])
    elif ('HTTP_HOST' in os.environ):
        self.__headers['Host'] = os.environ['HTTP_HOST']
        self.__target = self.__target_from_host(self.__headers['Host'])
    else:
        self.__target = _UNKNOWN_APP_VERSION
