requests

作成者: microsoft

Requestsを使用したHTTPクライアントのベストプラクティス(セッション、エラーハンドリング、タイムアウトを含む)

npx skills add https://github.com/microsoft/debugpy --skill requests

Skill: Requests

Best practices for HTTP client usage with Requests including sessions, error handling, and timeouts.

When to Use

Apply this skill when making HTTP requests with the Requests library — sessions, auth, error handling, retries, and file uploads.

Sessions

  • Use requests.Session() for connection pooling and persistent headers/cookies across multiple requests.
  • Configure session.headers for default auth tokens and user-agent strings.
  • Use session.mount() with HTTPAdapter for retry logic.

Error Handling

  • Always call response.raise_for_status() to surface HTTP errors as exceptions.
  • Always set timeout=(connect_timeout, read_timeout) — never use infinite timeouts.
  • Handle requests.ConnectionError, requests.Timeout, and requests.HTTPError explicitly.

Retries

  • Use urllib3.util.Retry with HTTPAdapter for automatic retries with backoff.
  • Configure status-based retries for transient errors (429, 500, 502, 503, 504).

Security

  • Never disable SSL verification (verify=False) in production.
  • Pass credentials via environment variables, not hardcoded strings.
  • Use auth= parameter for HTTP auth rather than manually setting headers.

Pitfalls

  • Don't forget timeouts — they default to None (infinite wait).
  • Don't use requests.get() for high-throughput — use sessions.
  • Close responses from streaming requests (stream=True) to release connections.

microsoftのその他のスキル

oss-growth
microsoft
OSS成長ハッカーのペルソナ
official
winapp-ui-automation
microsoft
コマンドラインからUI Automation(UIA)を使用して、実行中のWindowsアプリのUIを検査および操作します。AIエージェントや開発者がUIを検査する必要がある場合に使用します…
official
accessibility-aria-expert
microsoft
React/Fluent UIのWebビューにおけるアクセシビリティ問題を検出・修正します。スクリーンリーダー互換性のコードレビュー時、ARIAラベルの修正時、および…の確認時に使用します。
official
generate-canvas-app
microsoft
[DEPRECATED — 代わりに canvas-app を使用してください] 完全なPower Appsキャンバスアプリを生成します。
official
django
microsoft
Djangoウェブ開発のベストプラクティス(モデル、ビュー、テンプレート、テストを含む)
official
github-issue-creator
microsoft
生のメモ、エラーログ、音声入力、スクリーンショットを、簡潔なGitHub Flavored MarkdownのIssueレポートに変換します。ユーザーがバグ情報やエラーを貼り付けた際に使用します。
official
python-package-management
microsoft
依存関係管理にuvを使用し、タスク自動化にpoethepoetを使用します。
official
runtime-validation
microsoft
移行アプリケーションのランタイム検証 — テスト戦略(計画フェーズ)とテスト実行(検証フェーズ)をカバー:起動検証、…
official