Skip to content

Commit

Permalink
Merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ahopkins committed Dec 14, 2022
2 parents 3c3cfb1 + db39e12 commit 906207a
Show file tree
Hide file tree
Showing 15 changed files with 1,011 additions and 380 deletions.
26 changes: 21 additions & 5 deletions sanic/cli/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,32 @@ def run(self, parse_args=None):
except ValueError as e:
error_logger.exception(f"Failed to run app: {e}")
else:
if self.args.inspect or self.args.inspect_raw or self.args.trigger:
if (
self.args.inspect
or self.args.inspect_raw
or self.args.trigger
or self.args.scale is not None
):
os.environ["SANIC_IGNORE_PRODUCTION_WARNING"] = "true"
else:
for http_version in self.args.http:
app.prepare(**kwargs, version=http_version)

if self.args.inspect or self.args.inspect_raw or self.args.trigger:
action = self.args.trigger or (
"raw" if self.args.inspect_raw else "pretty"
)
if (
self.args.inspect
or self.args.inspect_raw
or self.args.trigger
or self.args.scale is not None
):
if self.args.scale is not None:
if self.args.scale <= 0:
error_logger.error("There must be at least 1 worker")
sys.exit(1)
action = f"scale={self.args.scale}"
else:
action = self.args.trigger or (
"raw" if self.args.inspect_raw else "pretty"
)
inspect(
app.config.INSPECTOR_HOST,
app.config.INSPECTOR_PORT,
Expand Down
6 changes: 6 additions & 0 deletions sanic/cli/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ def attach(self):
const="shutdown",
help=("Trigger all processes to shutdown"),
)
group.add_argument(
"--scale",
dest="scale",
type=int,
help=("Scale number of workers"),
)


class HTTPVersionGroup(Group):
Expand Down
11 changes: 11 additions & 0 deletions sanic/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from sanic.app import Sanic

import email.utils
import unicodedata
import uuid

from collections import defaultdict
Expand Down Expand Up @@ -1084,6 +1085,16 @@ def parse_multipart_form(body, boundary):
form_parameters["filename*"]
)
file_name = unquote(value, encoding=encoding)

# Normalize to NFC (Apple MacOS/iOS send NFD)
# Notes:
# - No effect for Windows, Linux or Android clients which
# already send NFC
# - Python open() is tricky (creates files in NFC no matter
# which form you use)
if file_name is not None:
file_name = unicodedata.normalize("NFC", file_name)

elif form_header_field == "content-type":
content_type = form_header_value
content_charset = form_parameters.get("charset", "utf-8")
Expand Down
36 changes: 36 additions & 0 deletions sanic/response/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from .convenience import (
empty,
file,
file_stream,
html,
json,
raw,
redirect,
text,
validate_file,
)
from .types import (
BaseHTTPResponse,
HTTPResponse,
JSONResponse,
ResponseStream,
json_dumps,
)


__all__ = (
"BaseHTTPResponse",
"HTTPResponse",
"JSONResponse",
"ResponseStream",
"empty",
"json",
"text",
"raw",
"html",
"validate_file",
"file",
"redirect",
"file_stream",
"json_dumps",
)

0 comments on commit 906207a

Please sign in to comment.