[Twisted-web] HTTPClient vs. HTTPClientFactory

Andrew McNabb amcnabb at mcnabbs.org
Thu Apr 17 20:32:03 EDT 2008

I'm still a little new to Twisted, so I was wondering if some kind soul
might be willing to help make sure I'm looking at things correctly.

First, I think I understand the difference between protocol factories
and protocols, but I could use a little reassurance.  My current
understanding is that the protocol factory holds the state that is
common to all connections, whereas the protocol holds the state that is
specific to a particular connection.  Is that an accurate understanding?

If that is correct, then what is the difference between a protocol
factory and a protocol for a client (like HTTPClient) where only one
connection is involved?  I'm a bit confused about why HTTPClientFactory
isn't a trivial class.  According to my current understanding, all of
the logic would be in HTTPClient.

I was also confused about why HTTPClientFactory would set
`self.protocol.followRedirect = followRedirect` in its __init__ method.
Since `self.protocol` is the HTTPPageGetter class, it appears that the
client factory is setting the followRedirect attribute for all
connections (associated with all HTTPClientFactories).  I was surprised
that HTTPClientFactory wouldn't set `self.followRedirect =
followRedirect`, in which case HTTPClient would look at

If someone could help clear up these questions for me, I feel like I
would understand Twisted a lot better.

Thank you!

Andrew McNabb
PGP Fingerprint: 8A17 B57C 6879 1863 DE55  8012 AB4D 6098 8826 6868
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-web/attachments/20080417/4d502555/attachment.pgp

More information about the Twisted-web mailing list