diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 54a4ffd..7e0a0ce 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,6 +11,7 @@ permissions: jobs: pypi-publish: runs-on: ubuntu-latest + environment: release permissions: id-token: write if: github.ref_type == 'tag' diff --git a/examples/request_http_proxy.py b/examples/request_http_proxy.py index b8d3d6f..95b1f68 100644 --- a/examples/request_http_proxy.py +++ b/examples/request_http_proxy.py @@ -3,7 +3,7 @@ import requests_raw res = requests_raw.raw( - url='https://httpbin.org/', + url='http://httpbin.org/', data=b"GET /get HTTP/1.1\r\nHost: httpbin.org\r\n\r\n", proxies={ "http": "http://127.0.0.1:8080", diff --git a/requests_raw/__version__.py b/requests_raw/__version__.py index 9d75bc6..b884aab 100644 --- a/requests_raw/__version__.py +++ b/requests_raw/__version__.py @@ -1,5 +1,5 @@ __title__ = 'requests-raw' -__description__ = 'Use requests to talk HTTP via a Raw sockets (To Test RFC Compliance)' +__description__ = 'HTTP communication through raw sockets using requests for RFC compliance testing' __url__ = 'https://github.com/realgam3/requests-raw' __version__ = '2.0.0' __build__ = 0x020000 diff --git a/requests_raw/connection.py b/requests_raw/connection.py index 94a2b87..4e5a88e 100644 --- a/requests_raw/connection.py +++ b/requests_raw/connection.py @@ -52,16 +52,11 @@ def request( enforce_content_length: bool = True, ) -> None: self.__method = method.lower() - if self.__method == __title__: - # HTTP Proxy + # HTTP Proxy + if self.__method == __title__ and not url.startswith("/"): _url = parse_url(url) - if _url.scheme and _url.netloc: - _body = body.split(b"/", 1) - if _body[0].endswith(b" "): - _body.insert(1, "{url.scheme}://{url.netloc}/".format(url=_url).encode()) - else: - _body.insert(1, b"/") - body = b"".join(_body) + _body = body.split(b"/", 1) + body = b"".join([_body[0], f"{_url.scheme}://{_url.netloc}/".encode(), _body[1]]) return super().request( method, url, body, headers, diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 1579ff7..0000000 --- a/setup.cfg +++ /dev/null @@ -1,6 +0,0 @@ -[bdist_wheel] -universal = 1 - -[metadata] -license_file = LICENSE -description-file = README.md \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index ea91be7..0000000 --- a/setup.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python3 - -from os import path -from setuptools import setup, find_packages - -__folder__ = path.abspath(path.dirname(__file__)) - -with open(path.join(__folder__, 'README.md')) as readme_file: - long_description = readme_file.read() - -about = {} -with open(path.join(__folder__, 'requests_raw', '__version__.py')) as about_file: - exec(about_file.read(), about) - -with open(path.join(__folder__, 'requirements.txt')) as req_file: - install_requires = req_file.readlines() - -setup( - name=about['__title__'], - version=about['__version__'], - description=about['__description__'], - long_description=long_description, - long_description_content_type='text/markdown', - author=about['__author__'], - author_email=about['__author_email__'], - packages=find_packages(exclude=['examples', 'tests']), - python_requires=">=3.7", - install_requires=install_requires, - license=about['__license__'], - platforms='any', - url=about["__url__"], - zip_safe=False, - classifiers=[ - 'Environment :: Web Environment', - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: Apache Software License', - 'Natural Language :: English', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - "Programming Language :: Python :: 3 :: Only", - 'Programming Language :: Python :: Implementation :: CPython', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Topic :: Internet :: WWW/HTTP', - 'Topic :: Software Development :: Libraries', - ], - extras_require={ - "security": [], - 'socks': ['PySocks>=1.5.6, !=1.5.7'], - "use_chardet_on_py3": ["chardet>=3.0.2,<6"], - }, - project_urls={ - 'Source': about["__url__"], - }, -)