@@ -96,6 +96,23 @@ def original_load(self, *args: Any, **kwargs: Any) -> None:
96
96
return original_load (self , * args , ** kwargs )
97
97
98
98
99
+ class AsyncTransportProtocolErrorHandler (AsyncTransport ):
100
+ """Retry on remote protocol error.
101
+
102
+ http://datatracker.ietf.org/doc/html/rfc2616#section-8.1.4 allows the server
103
+ # to close the connection at any time, we treat this as a normal and try again
104
+ # once since
105
+ """
106
+
107
+ @retry_connection_error (attempts = 2 , exception = httpx .RemoteProtocolError )
108
+ async def post (self , address , message , headers ):
109
+ return await super ().post (address , message , headers )
110
+
111
+ @retry_connection_error (attempts = 2 , exception = httpx .RemoteProtocolError )
112
+ async def get (self , address , params , headers ):
113
+ return await super ().get (address , params , headers )
114
+
115
+
99
116
async def _cached_document (url : str ) -> Document :
100
117
"""Load external XML document from disk."""
101
118
if url in _DOCUMENT_CACHE :
@@ -223,9 +240,9 @@ def __init__(
223
240
verify = _NO_VERIFY_SSL_CONTEXT , timeout = timeouts , limits = _HTTPX_LIMITS
224
241
)
225
242
self .transport = (
226
- AsyncTransport (client = client , wsdl_client = wsdl_client )
243
+ AsyncTransportProtocolErrorHandler (client = client , wsdl_client = wsdl_client )
227
244
if no_cache
228
- else AsyncTransport (
245
+ else AsyncTransportProtocolErrorHandler (
229
246
client = client , wsdl_client = wsdl_client , cache = SqliteCache ()
230
247
)
231
248
)
0 commit comments