Skip to content

Commit 39363d8

Browse files
authored
build: Using werkzeug library (#264)
* Using werkzeug library * Updating build templates * Added a venv * Fixed indentation * Changed to editable install * Installing werkzeug directly * Updated dependencies based on version * Adding werkzeug in tests pipelines * Updated tests pipeline * Added pyproject.toml * Updated build files * Added missing dependency * Updated verion in pyproject * Updated http_wsgi * Fixed http test error * Minor fixes and refactoring * Flake8 fixes
1 parent 48a5758 commit 39363d8

File tree

20 files changed

+75
-9120
lines changed

20 files changed

+75
-9120
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: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
import types
99
import typing
1010

11+
from werkzeug import formparser as _wk_parser
12+
from werkzeug import http as _wk_http
13+
from werkzeug.datastructures import (Headers, FileStorage, MultiDict,
14+
ImmutableMultiDict)
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]
179+
self.__files: MultiDict[str, FileStorage]
179180

180181
@property
181182
def url(self):
@@ -222,12 +223,9 @@ def _parse_form_data(self):
222223
content_length = len(body)
223224
mimetype, options = _wk_http.parse_options_header(content_type)
224225
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,
226+
_wk_parser.default_stream_factory, max_form_memory_size=None,
227+
max_content_length=None,
228+
cls=ImmutableMultiDict
231229
)
232230

233231
body_stream = io.BytesIO(body)

azure/functions/_http_wsgi.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
3-
from typing import Dict, List, Optional, Any
43
import logging
54
from io import BytesIO, StringIO
65
from os import linesep
6+
from typing import Dict, List, Optional, Any
77
from urllib.parse import ParseResult, urlparse, unquote_to_bytes
88
from wsgiref.headers import Headers
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+
return value.encode().decode("latin1")
1316

1417

1518
class WsgiRequest:
@@ -98,7 +101,7 @@ def to_environ(self, errors_buffer: StringIO) -> Dict[str, Any]:
98101

99102
# Ensure WSGI string fits in IOS-8859-1 code points
100103
for k, v in environ.items():
101-
if isinstance(v, string_types):
104+
if isinstance(v, (str,)):
102105
environ[k] = wsgi_encoding_dance(v)
103106

104107
# 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)