Agent Skillsmicrosoft/debugpy › requests

requests

GitHub

提供 Requests 库最佳实践,涵盖会话管理、错误处理、超时设置及重试机制,确保 HTTP 请求的安全性与稳定性。

.claude/skills/requests/SKILL.md microsoft/debugpy

触发场景

使用 Requests 库发起 HTTP 请求 配置会话连接池与持久化头部 处理 HTTP 异常与超时逻辑

安装

npx skills add microsoft/debugpy --skill requests -g -y
更多选项

非标准路径

npx skills add https://github.com/microsoft/debugpy/tree/main/.claude/skills/requests -g -y

不安装直接使用

npx skills use microsoft/debugpy@requests

指定 Agent (Claude Code)

npx skills add microsoft/debugpy --skill requests -a claude-code -g -y

安装 repo 全部 skill

npx skills add microsoft/debugpy --all -g -y

预览 repo 内 skill

npx skills add microsoft/debugpy --list

SKILL.md

Frontmatter
{
    "name": "requests",
    "description": "Best practices for HTTP client usage with Requests including sessions, error handling, and timeouts."
}

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.

版本历史

  • e5743d3 当前 2026-08-20 17:01

同 Skill 集合

.claude/skills/click/SKILL.md
.claude/skills/django/SKILL.md
.claude/skills/flask/SKILL.md
.claude/skills/jinja2/SKILL.md
.claude/skills/numpy/SKILL.md
.claude/skills/pytest/SKILL.md

元信息

文件数
0
版本
e5743d3
Hash
c6f0bbed
收录时间
2026-08-20 17:01

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-28 22:55
浙ICP备14020137号-1 $访客地图$