샘플
urllib3 2.7.0: ProxyManager, proxy_from_url
검증된 샘플 — pypi urllib3 2.7.0: ProxyManager, proxy_from_url. python 3.12 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: urllib3.ProxyManager initializes…
sha256:17554647578c60ed7b410052c22e791cd89f8933c6ffc6d90fc469a1e4675815
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 pip
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| python 3.12 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1python:3.12-alpine@sha256:d09d15e60962… |
2026-08-27 |
케이스
HOW- 목표
- verify pkg:pypi/urllib3@2.7.0
- 패키지
- 심벌
-
- urllib3.ProxyManager
- urllib3.proxy_from_url
- 생성일
- 2026-08-27T19:11:08Z
컨트랙트
- urllib3.ProxyManager initializes an HTTP/HTTPS proxy manager with target proxy URL and custom proxy headers
- urllib3.proxy_from_url constructs a ProxyManager instance from a URL string with proxy endpoint details
- urllib3.ProxyManager.connection_from_host creates proxy connection pools routing requests through the configured proxy
파일
- PROMPT.md
- csx.json
- requirements.txt
- sample.py
- spec.json
- test/contract.py
소스
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:pypi/urllib3@2.7.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/urllib3@2.7.0
Demonstrate these symbols/APIs:
- urllib3.ProxyManager
- urllib3.proxy_from_url
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:575184b151ddc3c18521e2dadaceb936f19e1348462be0c8a6b115f64c2914db","contract":["urllib3.ProxyManager initializes an HTTP/HTTPS proxy manager with target proxy URL and custom proxy headers","urllib3.proxy_from_url constructs a ProxyManager instance from a URL string with proxy endpoint details","urllib3.ProxyManager.connection_from_host creates proxy connection pools routing requests through the configured proxy"],"goal":"verify pkg:pypi/urllib3@2.7.0","kind":"HOW","packages":["pkg:pypi/urllib3@2.7.0"],"schemaVersion":1,"symbols":["urllib3.ProxyManager","urllib3.proxy_from_url"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/urllib3@2.7.0"],"schemaVersion":1,"subject":"pkg:pypi/urllib3@2.7.0","symbols":["urllib3.ProxyManager","urllib3.proxy_from_url"],"verifierAdapter":"python@1"}
urllib3==2.7.0
"""Sample demonstrating HTTP/HTTPS proxy configuration and management with urllib3."""
from typing import Dict, Optional
import urllib3
from urllib3 import ProxyManager, proxy_from_url
from urllib3.connectionpool import ConnectionPool
def create_proxy_manager(
proxy_url: str,
proxy_headers: Optional[Dict[str, str]] = None,
num_pools: int = 10,
maxsize: int = 1,
) -> ProxyManager:
"""Initialize a ProxyManager with custom proxy headers and connection pool settings."""
return ProxyManager(
proxy_url=proxy_url,
proxy_headers=proxy_headers,
num_pools=num_pools,
maxsize=maxsize,
)
def create_proxy_from_url(proxy_url: str, **kwargs) -> ProxyManager:
"""Construct a ProxyManager instance directly from a proxy URL string."""
return proxy_from_url(proxy_url, **kwargs)
def get_proxy_connection_pool(
manager: ProxyManager,
host: str,
port: Optional[int] = None,
scheme: str = "http",
) -> ConnectionPool:
"""Obtain the proxy connection pool for a specific destination host and scheme."""
return manager.connection_from_host(host=host, port=port, scheme=scheme)
{
"schemaVersion": 1,
"goal": "verify pkg:pypi/urllib3@2.7.0",
"kind": "HOW",
"packages": [
"pkg:pypi/urllib3@2.7.0"
],
"symbols": [
"urllib3.ProxyManager",
"urllib3.proxy_from_url"
]
}
"""Contract verification test for urllib3 ProxyManager and proxy_from_url utilities."""
import os
import sys
# Ensure project root is on sys.path for local module imports
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import urllib3
from urllib3 import ProxyManager
from urllib3.connectionpool import HTTPConnectionPool, HTTPSConnectionPool
from urllib3.util import Url
from sample import (
create_proxy_from_url,
create_proxy_manager,
get_proxy_connection_pool,
)
def test_proxy_manager_initialization() -> None:
"""Assertion 1: urllib3.ProxyManager initializes an HTTP/HTTPS proxy manager with target proxy URL and custom proxy headers."""
proxy_url = "http://proxy.example.com:8080"
headers = {"Proxy-Authorization": "Basic dXNlcjpwYXNz", "X-Proxy-Custom": "enabled"}
pm = create_proxy_manager(proxy_url=proxy_url, proxy_headers=headers)
assert isinstance(pm, ProxyManager), "Manager must be an instance of ProxyManager"
assert isinstance(pm.proxy, Url), "Proxy attribute must be a Url object"
assert pm.proxy.scheme == "http", f"Expected scheme http, got {pm.proxy.scheme}"
assert pm.proxy.host == "proxy.example.com", f"Expected host proxy.example.com, got {pm.proxy.host}"
assert pm.proxy.port == 8080, f"Expected port 8080, got {pm.proxy.port}"
assert pm.proxy_headers["Proxy-Authorization"] == "Basic dXNlcjpwYXNz"
assert pm.proxy_headers["X-Proxy-Custom"] == "enabled"
def test_proxy_from_url_construction() -> None:
"""Assertion 2: urllib3.proxy_from_url constructs a ProxyManager instance from a URL string with authentication and endpoint details."""
raw_url = "http://proxy2.example.com:3128"
pm = create_proxy_from_url(raw_url)
assert isinstance(pm, ProxyManager), "Constructed object must be a ProxyManager"
assert isinstance(pm.proxy, Url), "Proxy attribute must be a Url object"
assert pm.proxy.scheme == "http", f"Expected scheme http, got {pm.proxy.scheme}"
assert pm.proxy.host == "proxy2.example.com", f"Expected host proxy2.example.com, got {pm.proxy.host}"
assert pm.proxy.port == 3128, f"Expected port 3128, got {pm.proxy.port}"
def test_proxy_connection_pool_resolution() -> None:
"""Assertion 3: urllib3.ProxyManager.connection_from_host creates proxy connection pools routing requests through the configured proxy."""
pm = create_proxy_manager("http://proxy.example.com:8080")
# HTTP destination pool connects directly via the proxy host
http_pool = get_proxy_connection_pool(pm, host="api.example.com", port=80, scheme="http")
assert isinstance(http_pool, HTTPConnectionPool), "Must return HTTPConnectionPool for http scheme"
assert http_pool.proxy.host == "proxy.example.com", "HTTP pool proxy host mismatch"
assert http_pool.proxy.port == 8080, "HTTP pool proxy port mismatch"
# HTTPS destination pool connects to destination host via CONNECT tunnel through the proxy
https_pool = get_proxy_connection_pool(pm, host="secure.example.com", port=443, scheme="https")
assert isinstance(https_pool, HTTPSConnectionPool), "Must return HTTPSConnectionPool for https scheme"
assert https_pool.proxy.host == "proxy.example.com", "HTTPS pool proxy host mismatch"
assert https_pool.host == "secure.example.com", "HTTPS pool target host mismatch"
assert https_pool.port == 443, "HTTPS pool target port mismatch"
def main() -> None:
test_proxy_manager_initialization()
test_proxy_from_url_construction()
test_proxy_connection_pool_resolution()
print("All contract assertions passed successfully.")
if __name__ == "__main__":
main()
오리진 시더
익명