{"id":27239799,"url":"https://github.com/sesh/thttp","last_synced_at":"2025-04-10T19:13:59.912Z","repository":{"id":57679300,"uuid":"223013404","full_name":"sesh/thttp","owner":"sesh","description":"A lightweight wrapper around urllib","archived":false,"fork":false,"pushed_at":"2023-08-09T01:23:05.000Z","size":63,"stargazers_count":20,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-06T23:25:22.857Z","etag":null,"topics":["http","python","urllib"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sesh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2019-11-20T19:39:26.000Z","updated_at":"2024-10-17T17:08:27.000Z","dependencies_parsed_at":"2023-02-10T01:01:24.605Z","dependency_job_id":null,"html_url":"https://github.com/sesh/thttp","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sesh%2Fthttp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sesh%2Fthttp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sesh%2Fthttp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sesh%2Fthttp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sesh","download_url":"https://codeload.github.com/sesh/thttp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248280363,"owners_count":21077412,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http","python","urllib"],"created_at":"2025-04-10T19:13:59.343Z","updated_at":"2025-04-10T19:13:59.902Z","avatar_url":"https://github.com/sesh.png","language":"Python","readme":"# thttp\n\n`thttp` is a single file, lightweight, well-tested wrapper around `urllib` that's intended to be copied directly into your project.\n\nIt's features include:\n\n- Making GET, POST, PATCH, PUT, HEAD and OPTIONS requests\n- Sending query parameters with your request\n- Encoding JSON payloads for POST, PATCH and PUT requests\n- Encoding form-encoded payloads for POST, PATCH and PUT request\n- Sending custom headers with any request\n- Disabling SSL certificate verification for local testing / corporate proxies\n- Following (or not following) redirects\n- Sending through a CookieJar object that can be reused between requests\n- Authenticating with HTTP basic auth\n- Specifying a custom timeout for your request\n- Decompressing gzipped content in the response\n- Loading JSON from the response\n- Returning error responses instead of throwing exceptions from `urllib`\n- `pretty()` function for printing responses\n- Ability to upload files using the `{\"file\": open(\"file.png\", \"rb\")}` style\n\nFuture features:\n\n- Better detection of JSON responses\n- Improve handling of non-utf-8 requests\n- Improve handling of non-utf-8 responses\n\n_Note: this project is not intended to solve all use cases that can be achieved with urllib, requests, httpx, or other HTTP libraries. The intent is to provide a lightweight tool that simplifies some of the most common use cases for developers._\n\n\n## Installation\n\ncopy `thttp.py` directly into your project:\n\n```\ncurl https://raw.githubusercontent.com/sesh/thttp/main/thttp.py \u003e thttp.py\n```\n\nOr, install with `pip`:\n\n```\npython3 -m pip install thttp\n```\n\n\n## Basic Usage\n\nSee the tests for examples of usage, but, effectively it's as simple as:\n\n```python\nfrom thttp import request\n\nresponse = request(\"https://httpbingo.org/get\", params={\"data\": \"empty\"})\n\nresponse.json\n# {'args': {'data': ['empty']}, 'headers': {'Accept-Encoding': ['identity'], 'Fly-Client-Ip': ['45.76.105.111'], 'Fly-Forwarded-Port': ['443'], 'Fly-Forwarded-Proto': ['https'], 'Fly-Forwarded-Ssl': ['on'], 'Fly-Region': ['hkg'], 'Fly-Request-Id': ['01F6P2WQAY1NGPRDCXV9H60XW5'], 'Host': ['httpbingo.org'], 'User-Agent': ['Python-urllib/3.8'], 'Via': ['1.1 fly.io'], 'X-Forwarded-For': ['45.76.105.111, 77.83.142.42'], 'X-Forwarded-Port': ['443'], 'X-Forwarded-Proto': ['https'], 'X-Forwarded-Ssl': ['on'], 'X-Request-Start': ['t=1622091390302198']}, 'origin': '45.76.105.111, 77.83.142.42', 'url': 'https://httpbingo.org/get?data=empty'}\n\nresponse.status\n# 200\n```\n\n\n## Running the tests\n\n```sh\n\u003e python3 -m unittest thttp.py\n```\n\nAnd to check the coverage:\n\n```sh\n\u003e coverage run -m unittest thttp.py\n\u003e coverage html \u0026\u0026 open htmlcov/index.html\n```\n\nRun `black` before committing any changes.\n\n```sh\n\u003e black thttp.py\n```\n\n\n## Packaging for release\n\n```\nrm dist/*\npython3 -m build\npython3 -m twine upload dist/*\n```\n\n\n## License\n\nThis code is currently released under the [UNLICENSE](UNLICENSE.md) and considered public domain.\nIf more appropriate for your usage you may consider this project released under the [MIT License](LICENSE.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsesh%2Fthttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsesh%2Fthttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsesh%2Fthttp/lists"}