(use_proxy: bool)
| 167 | } |
| 168 | |
| 169 | def _request_once(use_proxy: bool) -> Dict[str, Any]: |
| 170 | session = _build_http_session(proxy_url if use_proxy else None) |
| 171 | started = time.perf_counter() |
| 172 | req_kwargs: Dict[str, Any] = { |
| 173 | "url": url, |
| 174 | "headers": headers or {}, |
| 175 | "timeout": timeout_seconds, |
| 176 | } |
| 177 | if json_body is not None: |
| 178 | req_kwargs["json"] = json_body |
| 179 | if method.upper() == "POST": |
| 180 | resp = session.post(**req_kwargs) |
| 181 | else: |
| 182 | resp = session.get(**req_kwargs) |
| 183 | cost = int((time.perf_counter() - started) * 1000) |
| 184 | return {"status": int(resp.status_code), "elapsed_ms": cost} |
| 185 | |
| 186 | if proxy_url: |
| 187 | try: |
no test coverage detected