判断是否应从 curl_cffi 回退到 urllib。
(self, error_message: str)
| 769 | raise Exception(f"Flow API text request failed: {error_msg}") |
| 770 | |
| 771 | def _should_fallback_to_urllib(self, error_message: str) -> bool: |
| 772 | """判断是否应从 curl_cffi 回退到 urllib。""" |
| 773 | error_lower = (error_message or "").lower() |
| 774 | return any( |
| 775 | keyword in error_lower |
| 776 | for keyword in [ |
| 777 | "curl: (6)", |
| 778 | "curl: (7)", |
| 779 | "curl: (28)", |
| 780 | "curl: (35)", |
| 781 | "curl: (52)", |
| 782 | "curl: (56)", |
| 783 | "connection timed out", |
| 784 | "could not connect", |
| 785 | "failed to connect", |
| 786 | "ssl connect error", |
| 787 | "tls connect error", |
| 788 | "network is unreachable", |
| 789 | ] |
| 790 | ) |
| 791 | |
| 792 | def _sync_json_request_via_urllib( |
| 793 | self, |