Skip to content

Commit da5a649

Browse files
committed
Using werkzeug library
1 parent 48a5758 commit da5a649

File tree

16 files changed

+29
-9049
lines changed

16 files changed

+29
-9049
lines changed

azure/functions/_abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import threading
88
import typing
99

10-
from azure.functions._thirdparty.werkzeug.datastructures import Headers
10+
from werkzeug.datastructures import Headers
1111

1212
T = typing.TypeVar('T')
1313

azure/functions/_http.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
import types
99
import typing
1010

11+
from multidict._multidict import MultiDict
12+
from werkzeug import formparser as _wk_parser
13+
from werkzeug import http as _wk_http
14+
from werkzeug.datastructures import Headers, FileStorage
15+
1116
from . import _abc
12-
from ._thirdparty.werkzeug import datastructures as _wk_datastructures
13-
from ._thirdparty.werkzeug import formparser as _wk_parser
14-
from ._thirdparty.werkzeug import http as _wk_http
15-
from ._thirdparty.werkzeug.datastructures import Headers
1617

1718

1819
class BaseHeaders(collections.abc.Mapping):
@@ -174,8 +175,8 @@ def __init__(self,
174175
self.__route_params = types.MappingProxyType(route_params or {})
175176
self.__body_bytes = body
176177
self.__form_parsed = False
177-
self.__form = None
178-
self.__files = None
178+
self.__form: MultiDict[str, str] = None
179+
self.__files:MultiDict[str, FileStorage] = None
179180

180181
@property
181182
def url(self):
@@ -216,18 +217,21 @@ def get_json(self) -> typing.Any:
216217
def _parse_form_data(self):
217218
if self.__form_parsed:
218219
return
219-
220+
"""
221+
stream_factory: TStreamFactory | None = None,
222+
max_form_memory_size: int | None = None,
223+
max_content_length: int | None = None,
224+
cls: type[MultiDict[str, t.Any]] | None = None,
225+
silent: bool = True,
226+
*,
227+
max_form_parts: int | None = None,
228+
"""
220229
body = self.get_body()
221230
content_type = self.headers.get('Content-Type', '')
222231
content_length = len(body)
223232
mimetype, options = _wk_http.parse_options_header(content_type)
224233
parser = _wk_parser.FormDataParser(
225-
_wk_parser.default_stream_factory,
226-
options.get('charset') or 'utf-8',
227-
'replace',
228-
None,
229-
None,
230-
_wk_datastructures.ImmutableMultiDict,
234+
_wk_parser.default_stream_factory
231235
)
232236

233237
body_stream = io.BytesIO(body)

azure/functions/_http_wsgi.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99

1010
from ._abc import Context
1111
from ._http import HttpRequest, HttpResponse
12-
from ._thirdparty.werkzeug._compat import string_types, wsgi_encoding_dance
12+
13+
14+
def wsgi_encoding_dance(value):
15+
if isinstance(value, str):
16+
return value.encode("latin-1")
17+
return value
1318

1419

1520
class WsgiRequest:
@@ -98,7 +103,7 @@ def to_environ(self, errors_buffer: StringIO) -> Dict[str, Any]:
98103

99104
# Ensure WSGI string fits in IOS-8859-1 code points
100105
for k, v in environ.items():
101-
if isinstance(v, string_types):
106+
if isinstance(v, (str,)):
102107
environ[k] = wsgi_encoding_dance(v)
103108

104109
# Remove None values

azure/functions/_thirdparty/werkzeug/LICENSE.rst

Lines changed: 0 additions & 28 deletions
This file was deleted.

azure/functions/_thirdparty/werkzeug/__init__.py

Whitespace-only changes.

azure/functions/_thirdparty/werkzeug/_compat.py

Lines changed: 0 additions & 219 deletions
This file was deleted.

0 commit comments

Comments
 (0)