用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/majiayu000/claude-skill-registry --skill httpx命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
LLM token logprobs and calibration. Per-decision confidence, ECE, Brier, reliability diagrams, low-confidence triage.
Analyze LLM token logprobs and calibration. Use for per-decision confidence, ECE, Brier scores, reliability diagrams, and low-confidence triage.
回顾最近 N 天的 Claude Code 使用记录——扫描原始会话数据,按主题分组汇总"我都做了什么",并从个人操作系统视角输出模式、风险与增删建议。当用户说 /recap、"看看我这几天做了什么"、"回顾一下我最近的会话"、"这两天我用 claude 干了啥"、"活动回顾" 时使用。
基于 SOC 职业分类
正在显示 SKILL.md
| name | httpx |
| description | A synchronous and asynchronous HTTP client for making requests and working with responses. |
| version | 0.28.1 |
| ecosystem | python |
| license | BSD-3-Clause |
| generated_with | gpt-5.2 |
import httpx
from httpx import AsyncClient, BasicAuth, Client, DigestAuth, NetRCAuth, Response
from httpx import ASGITransport, WSGITransport
import httpx
def fetch_json(url: str) -> dict:
response = httpx.get(url)
response.raise_for_status()
return response.json()
if __name__ == "__main__":
data = fetch_json("https://httpbin.org/json")
print(sorted(data.keys()))
httpx.get()/httpx.request() for quick scripts or single calls.httpx.Client once you have multiple requests.import httpx
def fetch_many(urls: list[str]) -> list[int]:
status_codes: list[int] = []
with httpx.Client() as client:
for url in urls:
r = client.get(url)
status_codes.append(r.status_code)
return status_codes
if __name__ == "__main__":
codes = fetch_many(["https://httpbin.org/status/200", "https://httpbin.org/status/204"])
print(codes)
httpx.Client() for connection pooling, cookie persistence, shared headers, proxy support, and HTTP/2 support (when configured).with httpx.Client() as client: (or call client.close()) to release resources.import asyncio
import httpx
async def fetch_text(url: str) -> str:
async with httpx.AsyncClient() as client:
r = await client.get(url)
r.raise_for_status()
return r.text
async def main() -> None:
text = await fetch_text("https://httpbin.org/uuid")
print(text.strip())
if __name__ == "__main__":
asyncio.run(main())
httpx.AsyncClient() for async I/O; always await request calls.async with to ensure the client is closed.import httpx
def fetch_with_basic_auth(url: str, username: str, password: str) -> int:
auth = httpx.BasicAuth(username, password)
with httpx.Client(auth=auth) as client:
r = client.get(url)
return r.status_code
if __name__ == "__main__":
# httpbin requires user/pass to match in this endpoint.
code = fetch_with_basic_auth("https://httpbin.org/basic-auth/user/pass", "user", "pass")
print(code)
client.get(..., auth=...)) or on the client (Client(auth=...)) depending on scope.DigestAuth and NetRCAuth.import httpx
async def asgi_app(scope, receive, send) -> None:
assert scope["type"] == "http"
await send(
{
"type": "http.response.start",
"status": 200,
"headers": [(b"content-type", b"text/plain")],
}
)
await send({"type": "http.response.body", "body": b"ok"})
def wsgi_app(environ, start_response):
start_response("200 OK", [("Content-Type", "text/plain")])
return [b"ok"]
def call_wsgi() -> str:
transport = httpx.WSGITransport(app=wsgi_app)
with httpx.Client(transport=transport, base_url="http://testserver") as client:
return client.get("/").text
async def call_asgi() -> str:
transport = httpx.ASGITransport(app=asgi_app)
async with httpx.AsyncClient(transport=transport, base_url="http://testserver") as client:
return (await client.get()).text
__name__ == :
(call_wsgi())
asyncio
(asyncio.run(call_asgi()))
transport=httpx.WSGITransport(app=...) or transport=httpx.ASGITransport(app=...).app= shortcut on Client/AsyncClient is removed in 0.28.0 (see Migration).with httpx.Client(...) as client: / async with httpx.AsyncClient(...) as client:client.close() when not using a context manager.auth= per request or set Client(auth=...).httpx.BasicAuth, httpx.DigestAuth, httpx.NetRCAuth.httpx.Auth and its auth_flow()/sync_auth_flow()/async_auth_flow().proxies= removed in 0.28.0)
Client(proxy="http://proxy.local:8080") for simple cases.mounts= (preferred over the removed proxies= argument).WSGITransport, ASGITransport.HTTPTransport, AsyncHTTPTransport (advanced usage).verify as a string path and using cert= are deprecated and may warn.verify=True, verify=False, or verify=<ssl.SSLContext> remain valid.content= with an explicit content-type.httpx.get() in a loop (no pooling)import httpx
def download_many() -> None:
for _ in range(10):
httpx.get("https://httpbin.org/get").raise_for_status()
if __name__ == "__main__":
download_many()
httpx.Client() for poolingimport httpx
def download_many() -> None:
with httpx.Client() as client:
for _ in range(10):
client.get("https://httpbin.org/get").raise_for_status()
if __name__ == "__main__":
download_many()
httpx.Client()import httpx
def fetch_once() -> int:
client = httpx.Client()
r = client.get("https://httpbin.org/status/200")
r.raise_for_status()
return r.status_code # client.close() never called
if __name__ == "__main__":
print(fetch_once())
client.close())import httpx
def fetch_once() -> int:
with httpx.Client() as client:
r = client.get("https://httpbin.org/status/200")
r.raise_for_status()
return r.status_code
if __name__ == "__main__":
print(fetch_once())
proxies= argument (0.28+) ⚠️import httpx
def build_client() -> httpx.Client:
return httpx.Client(proxies={"https": "http://proxy.local:8080"}) # removed in 0.28.0
if __name__ == "__main__":
build_client()
proxy= (or mounts= for complex routing)import httpx
def build_client() -> httpx.Client:
return httpx.Client(proxy="http://proxy.local:8080")
if __name__ == "__main__":
with build_client() as client:
print(client.get("https://httpbin.org/get").status_code)
httpx.Auth.auth_flow() doing async/non-HTTP I/Oimport asyncio
import httpx
async def get_token() -> str:
await asyncio.sleep(0)
return "token"
class TokenAuth(httpx.Auth):
def auth_flow(self, request: httpx.Request):
# BAD: running async I/O inside a sync generator.
token = asyncio.get_event_loop().run_until_complete(get_token())
request.headers["Authorization"] = f"Bearer {token}"
yield request
def main() -> None:
with httpx.Client(auth=TokenAuth()) as client:
client.get("https://httpbin.org/get")
if __name__ == "__main__":
main()
sync_auth_flow() and async_auth_flow()import asyncio
import threading
import httpx
class TokenAuth(httpx.Auth):
def __init__(self) -> None:
self._sync_lock = threading.RLock()
self._async_lock = asyncio.Lock()
def _sync_get_token(self) -> str:
with self._sync_lock:
return "token"
def sync_auth_flow(self, request: httpx.Request):
token = self._sync_get_token()
request.headers["Authorization"] = f"Bearer {token}"
yield request
async def _async_get_token(self) -> str:
async with self._async_lock:
await asyncio.sleep(0)
return "token"
async def async_auth_flow(self, request: httpx.Request):
token = await self._async_get_token()
request.headers["Authorization"] = f"Bearer {token}"
request
() -> :
httpx.Client(auth=TokenAuth()) client:
client.get().raise_for_status()
__name__ == :
main()
proxies= argument removed 🗑️ Removedproxy= for simple cases, or mounts= for complex routingimport httpx
# Before (0.27.x and earlier; removed in 0.28.0)
# client = httpx.Client(proxies={"https": "http://proxy.local:8080"})
# After (0.28.0+)
with httpx.Client(proxy="http://proxy.local:8080") as client:
r = client.get("https://httpbin.org/get")
print(r.status_code)
app= shortcut removed 🗑️ Removedtransport=httpx.ASGITransport(app=...) or transport=httpx.WSGITransport(app=...)import httpx
async def asgi_app(scope, receive, send) -> None:
await send({"type": "http.response.start", "status": 204, "headers": []})
await send({"type": "http.response.body", "body": b""})
# Before (removed in 0.28.0)
# client = httpx.AsyncClient(app=asgi_app)
# After
transport = httpx.ASGITransport(app=asgi_app)
content=... with a JSON content-type.import json
import httpx
def post_stable_json(url: str, payload: dict) -> int:
body = json.dumps(payload, separators=(",", ":"), sort_keys=True).encode("utf-8")
headers = {"content-type": "application/json"}
r = httpx.request("POST", url, content=body, headers=headers)
return r.status_code
if __name__ == "__main__":
print(post_stable_json("https://httpbin.org/post", {"b": 1, "a": 2}))
verify or using the cert argument is deprecated and will issue warnings.verify=True, verify=False, or verify=<ssl.SSLContext>. See new SSL configuration docs for details.httpx.Response.async with and await..netrc (optionally specify file).auth_flow() or sync_auth_flow()/async_auth_flow().Security Note:
All examples are designed for use within your own project directory and for safe, local development or controlled network requests. Never use these patterns to transmit, modify, or access data outside your intended project or environment. Do not copy/paste code into environments where you lack permission or understanding of the security implications.