curlify3 0.2__tar.gz → 0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: curlify3
3
- Version: 0.2
3
+ Version: 0.4
4
4
  Summary: yet another library to convert request object to curl command
5
5
  Home-page: https://github.com/shpaker/curlify3
6
6
  Author: A.Shpak
@@ -20,10 +20,11 @@ Description-Content-Type: text/markdown
20
20
  [![PyPI](https://img.shields.io/pypi/v/curlify3.svg)](https://pypi.python.org/pypi/curlify3)
21
21
  [![PyPI](https://img.shields.io/pypi/dm/curlify3.svg)](https://pypi.python.org/pypi/curlify3)
22
22
 
23
- ### Support request's objects of:
23
+ ### Support request's objects from:
24
24
 
25
25
  - requests
26
26
  - httpx
27
+ - aiohttp server
27
28
  - starlette/fastapi
28
29
 
29
30
  ## Installation
@@ -3,10 +3,11 @@
3
3
  [![PyPI](https://img.shields.io/pypi/v/curlify3.svg)](https://pypi.python.org/pypi/curlify3)
4
4
  [![PyPI](https://img.shields.io/pypi/dm/curlify3.svg)](https://pypi.python.org/pypi/curlify3)
5
5
 
6
- ### Support request's objects of:
6
+ ### Support request's objects from:
7
7
 
8
8
  - requests
9
9
  - httpx
10
+ - aiohttp server
10
11
  - starlette/fastapi
11
12
 
12
13
  ## Installation
@@ -1,6 +1,6 @@
1
1
  from curlify3._curl import to_curl, to_curl_async
2
2
 
3
- __version__ = "0.2"
3
+ __version__ = "0.4"
4
4
  __all__ = [
5
5
  "to_curl",
6
6
  "to_curl_async",
@@ -29,6 +29,7 @@ def make_curl_cookies(cookies):
29
29
 
30
30
  def make_multipart_curl_args(body):
31
31
  body_parts = []
32
+ body = body.encode() if isinstance(body, str) else body
32
33
  for matched in MULTIPART_FORM_DATA.finditer(body):
33
34
  groups = matched.groups()
34
35
  body_parts.append(f"-F '{groups[0].decode()}={groups[1].decode()}'")
@@ -38,10 +39,7 @@ def make_multipart_curl_args(body):
38
39
  return " ".join(body_parts)
39
40
 
40
41
 
41
- def make_curl_body(
42
- body,
43
- headers,
44
- ):
42
+ def make_curl_body(body, headers):
45
43
  if "multipart" in headers.get("content-type", ""):
46
44
  return make_multipart_curl_args(body)
47
45
  if not body:
@@ -0,0 +1,15 @@
1
+ from aiohttp import web
2
+
3
+ from curlify3._base import AsyncBaseRequestData
4
+
5
+
6
+ class AiohttpServerRequest(AsyncBaseRequestData):
7
+ _instance_of = web.Request
8
+
9
+ async def body(self):
10
+ data = await self._request.read()
11
+ try:
12
+ return data.decode()
13
+ except UnicodeDecodeError:
14
+ pass
15
+ return data
@@ -15,7 +15,7 @@ class HttpxRequest(BaseRequestData):
15
15
  return data
16
16
 
17
17
 
18
- class AsyncHttpxRequest(AsyncBaseRequestData, HttpxRequest):
18
+ class AsyncHttpxRequest(AsyncBaseRequestData):
19
19
  _instance_of = httpx.Request
20
20
 
21
21
  async def body(self):
@@ -22,6 +22,12 @@ with suppress(ImportError):
22
22
  _REQUEST_DATA_CLASSES_ASYNC.append(AsyncHttpxRequest)
23
23
 
24
24
 
25
+ with suppress(ImportError):
26
+ from curlify3._req_aiohttp import AiohttpServerRequest
27
+
28
+ _REQUEST_DATA_CLASSES_ASYNC.append(AiohttpServerRequest)
29
+
30
+
25
31
  with suppress(ImportError):
26
32
  from curlify3._req_starlette import StarletteRequest
27
33
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "curlify3"
3
- version = "0.2"
3
+ version = "0.4"
4
4
  description = "yet another library to convert request object to curl command"
5
5
  authors = ["A.Shpak <aleksander.shpak.als@gmail.com>"]
6
6
  readme = "README.md"
@@ -15,8 +15,8 @@ requests = "^2.32.3"
15
15
  httpx = "^0.27.2"
16
16
  fastapi = "^0.115.4"
17
17
  isort = "^5.13.2"
18
-
19
- [tool.poetry.group.tests.dependencies]
18
+ aiohttp = "^3.10.10"
19
+ pytest-aiohttp = "^1.0.5"
20
20
  pytest = "^8.3.3"
21
21
  pytest-asyncio = "^0.24.0"
22
22
  pytest-httpx = "^0.33.0"
File without changes
File without changes