Python package which builds on pypac to add pac file support for httplib2 Http
Project description
pypac4http2
Python package which builds on pypac to add pac file support for httplib2 Http
This package adds proxy auto configure pac support to the httplib2 library Http classby sub-classing the class and adding a new constructor parameter for a resolver class.
Installation
pip install pypac4http2
Usage
HttpPac Class
The HttpPac class extends httplib2.Http and automatically resolves the proxy for each request using a PAC file.
from pypac4http2 import HttpPac
# Automatically discover PAC using OS settings or WPAD
http = HttpPac()
response, content = http.request("http://example.org")
# Specify a PAC URL
http = HttpPac(pac_url="http://internal.corp/proxy.pac")
response, content = http.request("http://example.org")
# Provide PAC as a JavaScript string
pac_js = "function FindProxyForURL(url, host) { return 'PROXY proxy:8080'; }"
http = HttpPac(pac_js=pac_js)
response, content = http.request("http://example.org")
# The library also supports the PAC_URL environment variable:
# export PAC_URL=http://internal.corp/proxy.pac
Usage with Google API Client
HttpPac is designed to be a drop-in replacement for httplib2.Http, making it ideal for use with the Google API Python Client.
from googleapiclient.discovery import build
from pypac4http2 import HttpPac
# Initialize HttpPac for auto-discovery (or via PAC_URL)
http = HttpPac()
# Build the service using the proxy-aware http object
service = build('drive', 'v3', http=http)
# All API calls will now automatically resolve proxies via PAC
files = service.files().list().execute()
CLI Tool
The package includes a CLI tool pypac4http2 to resolve proxies for a given URL.
# Resolve proxy using OS auto-discovery (or PAC_URL env var if set)
pypac4http2 https://google.com
# Resolve proxy using a specific PAC URL
pypac4http2 --pac-url http://example.com/proxy.pac https://google.com
# Resolve proxy using a PAC JavaScript string
pypac4http2 --pac-js "function FindProxyForURL(url, host) { return 'DIRECT'; }" https://google.com
Output Example:
Proxy choice: PROXY proxy.example.com:8080
{
"target_url": "https://google.com",
"pac_result": "PROXY proxy.example.com:8080",
"proxy_info": {
"proxy_type": "HTTP",
"proxy_host": "proxy.example.com",
"proxy_port": 8080
}
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pypac4http2-0.0.4.tar.gz.
File metadata
- Download URL: pypac4http2-0.0.4.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
826f04301107d29847d6426d8023dff6491553e854bc267b81c41904a7f9ecf3
|
|
| MD5 |
7403862a2e424ff21e848fccce103870
|
|
| BLAKE2b-256 |
d7cd3a144c7dc379eab39eef4984815b7c4e38e2842c04c1fc1c4f8e0ed8a05a
|
Provenance
The following attestation bundles were made for pypac4http2-0.0.4.tar.gz:
Publisher:
publish.yml on MikeMoore63/pypac4http2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pypac4http2-0.0.4.tar.gz -
Subject digest:
826f04301107d29847d6426d8023dff6491553e854bc267b81c41904a7f9ecf3 - Sigstore transparency entry: 852466139
- Sigstore integration time:
-
Permalink:
MikeMoore63/pypac4http2@26148b53e34e30f66e332303bd88398218605173 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/MikeMoore63
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@26148b53e34e30f66e332303bd88398218605173 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pypac4http2-0.0.4-py3-none-any.whl.
File metadata
- Download URL: pypac4http2-0.0.4-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e5ab10d58870c5ebd442781aeaa60cc48cfcae68b29ee8cb431ef68a258acdd
|
|
| MD5 |
ca556d5d07b118efaf08bd24097f8e73
|
|
| BLAKE2b-256 |
832776160ad2e326d871901e39fcc955309207c921cbea2eece18407e740f4c4
|
Provenance
The following attestation bundles were made for pypac4http2-0.0.4-py3-none-any.whl:
Publisher:
publish.yml on MikeMoore63/pypac4http2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pypac4http2-0.0.4-py3-none-any.whl -
Subject digest:
6e5ab10d58870c5ebd442781aeaa60cc48cfcae68b29ee8cb431ef68a258acdd - Sigstore transparency entry: 852466199
- Sigstore integration time:
-
Permalink:
MikeMoore63/pypac4http2@26148b53e34e30f66e332303bd88398218605173 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/MikeMoore63
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@26148b53e34e30f66e332303bd88398218605173 -
Trigger Event:
release
-
Statement type: