Proxy
defrank opened this issue · comments
AsyncProxy - Python Programming Task
Your task is to build an asynchronous HTTP proxy (see definition in RFC2616) complying to the requirements specified below.
Requirements
- README
- rfc2616
- Range requests must be supported as defined in RFC2616, but also via
range
query
parameter. - HTTP 416 error must be returned in case where both header and query parameter are
specified, but with a different value. - Program must start with a single command
docker-compose up
. - Proxy must be reachable at
http://<docker-host>:8080
. - Usage statistics must be available at
http://<docker-host>:8080/stats
- total bytes transferred
- uptime
- Code must run with Python 3.5+.
- Code must be delivered as a link to public GitHub repository.
Dev
Research
Bookmarks
- Proxy specific
- 1.3 proxy
- Range specific
- 3.12 Range Units
- 10.4.17 416 Requested Range Not Satisfiable
- 14.16 Content-Range
- 14.35 Range
- 19.2 Internet Media Type multipart/byteranges
- Misc
- 5.1.2 Request-URI
- 14.10 Connection
Assumptions
- async (in async HTTP proxy) is in regards to handling requests asynchronously. This will be covered by the framework (e.g., Django, Tornado, BottlePy). Assuming gevents (greenlets)'s multithreading is close enough to async
- Proxy server is transparent, not anonymous
range
query parameter must be lowercase, but header is handled case-insensitively
*total_bytes_transferred
refers only to the content length of responses sent from the proxy server to the client. Does not include headers, cookies, or request data.uptime
is server uptime, not transfer time- No gzip support for client
- No support for streaming
- /stats can return JSON formatted values
Frameworks
- async Python web frameworks
- synchronous web frameworks
Todo
- Choose async framework: BottlePy with gevent(greenlets)
- Implement basic transparent proxy
- Implement stats using SQLite to store the data
- Support proxy HEAD, GET, POST, PUT, DELETE
- Add support for range requests
- Proxy server
uptime
-
total_bytes_transferred
of just response content length
Future
- Handle response content as a file or buffer to save memory
- Use Python 3.5
async
andawait
... - Support gzip encoding responses to client
- Support streaming