--- doc/web/examples/httpclient.py.orig	2009-01-13 14:49:57.297372317 -0800
+++ doc/web/examples/httpclient.py	2009-01-13 15:28:05.575555000 -0800
@@ -35,13 +35,23 @@
 def main(reactor, url):
     cc = ClientCreator(reactor, HTTP11ClientProtocol)
     scheme, host, port, path = _parse(url)
-    if scheme != 'http':
+    if scheme == 'http':
+        d = cc.connectTCP(host, port)
+    elif scheme == 'https':
+        from twisted.internet.ssl import ClientContextFactory
+        contextFactory = ClientContextFactory()
+        d = cc.connectSSL(host, port, contextFactory)
+    else:
         raise SystemExit("Unsupported scheme: %r" % (scheme,))
-    d = cc.connectTCP(host, port)
     def cbConnected(proto):
+        # XXX This port information is redundant with the numbers in t.w.client._parse
+        defaultPorts = {'http': 80, 'https': 443}
+        host_header = host
+        if defaultPorts[scheme] != port:
+            host_header += ':%d' % port
         return proto.request(Request(
                 'GET', path,
-                Headers({'host': [host], 'user-agent': ['Twisted/%s (httpclient.py)' % (version.short(),)]}),
+                Headers({'host': [host_header], 'user-agent': ['Twisted/%s (httpclient.py)' % (version.short(),)]}),
                 None))
     d.addCallback(cbConnected)
     def cbResponse(response):
