python-http_request 0.0.5.1__tar.gz → 0.0.5.3__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: python-http_request
3
- Version: 0.0.5.1
3
+ Version: 0.0.5.3
4
4
  Summary: Python http response utils.
5
5
  Home-page: https://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/python-http_request
6
6
  License: MIT
@@ -87,8 +87,8 @@ def ensure_bytes(s, /) -> Buffer:
87
87
 
88
88
 
89
89
  def encode_multipart_data(
90
- data: Mapping[str, Any],
91
- files: Mapping[str, Buffer | SupportsRead[Buffer] | Iterable[Buffer]],
90
+ data: None | Mapping[str, Any] = None,
91
+ files: None | Mapping[str, Buffer | SupportsRead[Buffer] | Iterable[Buffer]] = None,
92
92
  boundary: None | str = None,
93
93
  ) -> tuple[dict, Iterator[Buffer]]:
94
94
  if not boundary:
@@ -96,6 +96,8 @@ def encode_multipart_data(
96
96
  headers = {"Content-Type": f"multipart/form-data; boundary={boundary}"}
97
97
 
98
98
  def encode_data(data) -> Iterator[Buffer]:
99
+ if not data:
100
+ return
99
101
  if isinstance(data, Mapping):
100
102
  data = ItemsView(data)
101
103
  for name, value in data:
@@ -105,6 +107,8 @@ def encode_multipart_data(
105
107
  yield b"\r\n"
106
108
 
107
109
  def encode_files(files) -> Iterator[Buffer]:
110
+ if not files:
111
+ return
108
112
  if isinstance(files, Mapping):
109
113
  files = ItemsView(files)
110
114
  for name, file in files:
@@ -123,8 +127,8 @@ def encode_multipart_data(
123
127
 
124
128
 
125
129
  def encode_multipart_data_async(
126
- data: Mapping[str, Any],
127
- files: Mapping[str, Buffer | SupportsRead[Buffer] | Iterable[Buffer] | AsyncIterable[Buffer]],
130
+ data: None | Mapping[str, Any] = None,
131
+ files: None | Mapping[str, Buffer | SupportsRead[Buffer] | Iterable[Buffer] | AsyncIterable[Buffer]] = None,
128
132
  boundary: None | str = None,
129
133
  ) -> tuple[dict, AsyncIterator[Buffer]]:
130
134
  if not boundary:
@@ -132,6 +136,8 @@ def encode_multipart_data_async(
132
136
  headers = {"Content-Type": f"multipart/form-data; boundary={boundary}"}
133
137
 
134
138
  async def encode_data(data) -> AsyncIterator[Buffer]:
139
+ if not data:
140
+ return
135
141
  if isinstance(data, Mapping):
136
142
  data = ItemsView(data)
137
143
  for name, value in data:
@@ -141,6 +147,8 @@ def encode_multipart_data_async(
141
147
  yield b"\r\n"
142
148
 
143
149
  async def encode_files(files) -> AsyncIterator[Buffer]:
150
+ if not files:
151
+ return
144
152
  if isinstance(files, Mapping):
145
153
  files = ItemsView(files)
146
154
  for name, file in files:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-http_request"
3
- version = "0.0.5.1"
3
+ version = "0.0.5.3"
4
4
  description = "Python http response utils."
5
5
  authors = ["ChenyangGao <wosiwujm@gmail.com>"]
6
6
  license = "MIT"