@@ -190,30 +190,37 @@ def _set_socket_keepalive(sock) -> None:
190190 LOG .debug ("Unable to set %s on socket." % option_name , exc_info = True )
191191
192192
193- class KeepaliveHTTPConnection ( HTTPConnectionWithTimeout ):
193+ class _KeepaliveConnectionMixin ( object ):
194194 """
195- httplib2 HTTP connection that enables TCP keepalive once connected .
195+ Mixin that enables TCP keepalive once the connection is established .
196196
197- Passed to ``httplib2.Http.request()`` as its ``connection_type`` so that the
198- bundled httplib2 does not need to be modified.
197+ Must be listed before the httplib2 connection class so that this
198+ ``connect()`` runs and delegates to the real one. ``self.sock`` is the
199+ SSL-wrapped socket for HTTPS, which delegates ``setsockopt`` to the socket
200+ underneath.
199201 """
200202
201203 def connect (self ) -> None :
202204 super ().connect ()
203205 _set_socket_keepalive (self .sock )
204206
205207
206- class KeepaliveHTTPSConnection ( HTTPSConnectionWithTimeout ):
208+ class KeepaliveHTTPConnection ( _KeepaliveConnectionMixin , HTTPConnectionWithTimeout ):
207209 """
208- httplib2 HTTPS connection that enables TCP keepalive once connected.
210+ httplib2 HTTP connection that enables TCP keepalive once connected.
209211
210212 Passed to ``httplib2.Http.request()`` as its ``connection_type`` so that the
211213 bundled httplib2 does not need to be modified.
212214 """
213215
214- def connect (self ) -> None :
215- super ().connect ()
216- _set_socket_keepalive (self .sock )
216+
217+ class KeepaliveHTTPSConnection (_KeepaliveConnectionMixin , HTTPSConnectionWithTimeout ):
218+ """
219+ httplib2 HTTPS connection that enables TCP keepalive once connected.
220+
221+ Passed to ``httplib2.Http.request()`` as its ``connection_type`` so that the
222+ bundled httplib2 does not need to be modified.
223+ """
217224
218225
219226# ----------------------------------------------------------------------------
0 commit comments