title: python - With urllib3 Retry add solution for retries based on response content
body: <p>I am using the usual urllib3 solution for requests to have retry and timeout handling:</p>
  <pre><code>DEFAULT_TIMEOUT = 20 # seconds
  
  class TimeoutHTTPAdapter(HTTPAdapter):
      def __init__(self, *args, **kwargs):
          self.timeout = DEFAULT_TIMEOUT
          if &quot;timeout&quot; in kwargs:
              self.timeout = kwargs[&quot;timeout&quot;]
              del kwargs[&quot;timeout&quot;]
          super().__init__(*args, **kwargs)
  
      def send(self, request, **kwargs):
          timeout = kwargs.get(&quot;timeout&quot;)
          if timeout is None:
              kwargs[&quot;timeout&quot;] = self.timeout
          return super().send(request, **kwargs)
  
  retry_strategy = Retry(
      total=5,
      backoff_factor=2,
      status_forcelist=[400, 408, 429, 502, 503, 504, 508],
      method_whitelist=[&quot;HEAD&quot;, &quot;GET&quot;, &quot;OPTIONS&quot;, &quot;POST&quot;]
  )
  adapter = TimeoutHTTPAdapter(max_retries=retry_strategy)
  http = requests.Session()
  http.mount(&quot;https://&quot;, adapter)
  http.mount(&quot;http://&quot;, adapter)
  </code></pre>
  <p>But sometimes I receive post request responses with response code 200 who contain error messages and service timeouts.</p>
  <p>Is it possible to handle such content based retries with the build in retry solution of urllib3 or with other solutions?</p>