As specified by the definition:
- hostname is the host name (without the port number or square brackets)
- host is the host name and port number
So depending on your needs, you should use the one or the other. Most of the HTTP communication will go on default port 80, so you might omit it then. On the other hand, if you suspect that you need to take regard to non-standard port settings, you need to include that information in your source code as well.