<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_canonical_host(self, canonical_host):
 """ Set host and port from a canonical host string as for the Host HTTP header specification. """

        parts = canonical_host.lower().split(":")
        self.host = parts[0]
        if len(parts) > 1 and parts[1]:
            self.port = int(parts[1])
        else:
            self.port = None