|
46 | 46 |
|
47 | 47 | # For cross-platform keyboard input |
48 | 48 | import readchar |
| 49 | +import ssl |
| 50 | +import truststore |
| 51 | + |
| 52 | +ssl_context = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT) |
| 53 | +client = httpx.Client(verify=ssl_context) |
49 | 54 |
|
50 | 55 | # Constants |
51 | 56 | AI_CHOICES = { |
@@ -397,10 +402,10 @@ def download_template_from_github(ai_assistant: str, download_dir: Path, *, verb |
397 | 402 | api_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/releases/latest" |
398 | 403 |
|
399 | 404 | try: |
400 | | - response = httpx.get(api_url, timeout=30, follow_redirects=True) |
| 405 | + response = client.get(api_url, timeout=30, follow_redirects=True) |
401 | 406 | response.raise_for_status() |
402 | 407 | release_data = response.json() |
403 | | - except httpx.RequestError as e: |
| 408 | + except client.RequestError as e: |
404 | 409 | if verbose: |
405 | 410 | console.print(f"[red]Error fetching release information:[/red] {e}") |
406 | 411 | raise typer.Exit(1) |
@@ -437,7 +442,7 @@ def download_template_from_github(ai_assistant: str, download_dir: Path, *, verb |
437 | 442 | console.print(f"[cyan]Downloading template...[/cyan]") |
438 | 443 |
|
439 | 444 | try: |
440 | | - with httpx.stream("GET", download_url, timeout=30, follow_redirects=True) as response: |
| 445 | + with client.stream("GET", download_url, timeout=30, follow_redirects=True) as response: |
441 | 446 | response.raise_for_status() |
442 | 447 | total_size = int(response.headers.get('content-length', 0)) |
443 | 448 |
|
@@ -466,7 +471,7 @@ def download_template_from_github(ai_assistant: str, download_dir: Path, *, verb |
466 | 471 | for chunk in response.iter_bytes(chunk_size=8192): |
467 | 472 | f.write(chunk) |
468 | 473 |
|
469 | | - except httpx.RequestError as e: |
| 474 | + except client.RequestError as e: |
470 | 475 | if verbose: |
471 | 476 | console.print(f"[red]Error downloading template:[/red] {e}") |
472 | 477 | if zip_path.exists(): |
@@ -843,9 +848,9 @@ def check(): |
843 | 848 | # Check if we have internet connectivity by trying to reach GitHub API |
844 | 849 | console.print("[cyan]Checking internet connectivity...[/cyan]") |
845 | 850 | try: |
846 | | - response = httpx.get("https://api.github.com", timeout=5, follow_redirects=True) |
| 851 | + response = client.get("https://api.github.com", timeout=5, follow_redirects=True) |
847 | 852 | console.print("[green]✓[/green] Internet connection available") |
848 | | - except httpx.RequestError: |
| 853 | + except client.RequestError: |
849 | 854 | console.print("[red]✗[/red] No internet connection - required for downloading templates") |
850 | 855 | console.print("[yellow]Please check your internet connection[/yellow]") |
851 | 856 |
|
|
0 commit comments