quickproxy
A lightweight, asynchronous, programmable HTTP proxy for python. Built with Tornado.
## Use
#### A simple proxy:
import quickproxy quickproxy.run_proxy(port=8080)
#### A reverse proxy:
This proxy will fetch responses from an AWS s3 bucket with the same ID as the request’s hostname.
- def callback(request):
request.host = request.host+”.s3-website-us-east-1.amazonaws.com” request.port = 80 return request
quickproxy.run_proxy(port=8080, req_callback=callback)
## Reference
Quickproxy exposes just one function:
- run_proxy(port,
methods=[‘GET’, ‘POST’], req_callback=DEFAULT_CALLBACK, resp_callback=DEFAULT_CALLBACK, err_callback=DEFAULT_CALLBACK, start_ioloop=True)
It runs a proxy on the specified port. You can pass the following parameters to configure quickproxy:
methods: the HTTP methods this proxy will support
- req_callback: a callback that is passed a RequestObj that it should
modify and then return. By default this is the identity function.
- resp_callback: a callback that is given a ResponseObj that it should
modify and then return. By default this is the identity function.
- err_callback: in the case of an error, this callback will be called.
there’s no difference between how this and the resp_callback are used. By default this is the identity function.
- start_ioloop: if True (default), the tornado IOLoop will be started
immediately.
### Request callback functions
The request callback should receive a RequestObj and return a RequestObj.
- request_callback(requestobj)
return requestobj
The RequestObj is a python object with the following attributes that can be modified before it is returned:
protocol: either ‘http’ or ‘https’
host: the destination hostname of the request
port: the port for the request
path: the path of the request (‘/index.html’ for example)
query: the query string (‘?key=value&other=value’)
fragment: the hash fragment (‘#fragment’)
method: request method (‘GET’, ‘POST’, etc)
username: always passed as None, but you can set it to override the user
password: None, but can be set to override the password
body: request body as a string
- headers: a dictionary of header / value pairs
(for example {‘Content-Type’: ‘text/plain’, ‘Content-Length’: 200})
follow_redirects: true to follow redirects before returning a response
### Response callback functions
The response and error callbacks should receive a ResponseObj and return a ResponseObj, similar to the request callback above.
The ResponseObj is a python object with the following attributes that can be modified before it is returned:
code: response code, such as 200 for ‘OK’
headers: the response headers
- pass_headers: a list or set of headers to pass along in the response. All
other headers will be stripped out. By default this includes:
(‘Date’, ‘Cache-Control’, ‘Server’, ‘Content-Type’, ‘Location’)
body: response body as a string
## Credits
Much of this code was adopted from Senko’s tornado-proxy:
https://github.com/senko/tornado-proxy
…which is itself based on the code by Bill Janssen posted to: http://groups.google.com/group/python-tornado/msg/7bea08e7a049cf26
Metadata
Release files for quickproxy 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| quickproxy-0.2.0.tar.gz | 6.8 kB | Without provenance | Details for quickproxy-0.2.0.tar.gz |
Release files / quickproxy-0.2.0.tar.gz
| Download URL | quickproxy-0.2.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a434e44fd028f0558b03160bc6c93167dbe237263773ee37c14b5f057409bb0
|
|
BLAKE2b-256 checksum How to use checksums |
27c73d03e61f576c0dd300c97fc9d780d152aed0841633bfd4dcbb79d7eedaab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for quickproxy 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.