[Twisted-web] HTTPClient vs. HTTPClientFactory

Andrew Bennetts andrew-twisted at puzzling.org
Fri Apr 18 05:18:23 EDT 2008


Matthew Glubb wrote:
> On 18 Apr 2008, at 01:32, Andrew McNabb wrote:
[...]
>
>> 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.
>
[...]
> instantiation of your ClientProtocol when successfully connected. I  
> agree that 'ClientProtocolFactory' is somewhat misleading as it  
> indicates that it is possible to create more than one ClientProtocol  
> from your factory. Within normal design patterns, this would be true,  
> but in this case your ClientProtocolFactory will only ever create one  
> instance of your ClientProtocol (unless you are doing something *really* 
> funky - and probably bad!).

To put it another way, there's a ClientFactory because even though there's often
only a single client connection, something still needs to build the protocol
instance for the connection.  The factory is that something.

-Andrew.




More information about the Twisted-web mailing list