mirror of https://github.com/encode/starlette.git
parent
65bfd74307
commit
9d4d5a5f3b
|
@ -272,6 +272,9 @@ class RangeNotSatisfiable(Exception):
|
||||||
self.max_size = max_size
|
self.max_size = max_size
|
||||||
|
|
||||||
|
|
||||||
|
_RANGE_PATTERN = re.compile(r"(\d*)-(\d*)")
|
||||||
|
|
||||||
|
|
||||||
class FileResponse(Response):
|
class FileResponse(Response):
|
||||||
chunk_size = 64 * 1024
|
chunk_size = 64 * 1024
|
||||||
|
|
||||||
|
@ -453,7 +456,7 @@ class FileResponse(Response):
|
||||||
int(_[0]) if _[0] else file_size - int(_[1]),
|
int(_[0]) if _[0] else file_size - int(_[1]),
|
||||||
int(_[1]) + 1 if _[0] and _[1] and int(_[1]) < file_size else file_size,
|
int(_[1]) + 1 if _[0] and _[1] and int(_[1]) < file_size else file_size,
|
||||||
)
|
)
|
||||||
for _ in re.findall(r"(\d*)-(\d*)", range_)
|
for _ in _RANGE_PATTERN.findall(range_)
|
||||||
if _ != ("", "")
|
if _ != ("", "")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@ class EndpointInfo(typing.NamedTuple):
|
||||||
func: typing.Callable[..., typing.Any]
|
func: typing.Callable[..., typing.Any]
|
||||||
|
|
||||||
|
|
||||||
|
_remove_converter_pattern = re.compile(r":\w+}")
|
||||||
|
|
||||||
|
|
||||||
class BaseSchemaGenerator:
|
class BaseSchemaGenerator:
|
||||||
def get_schema(self, routes: list[BaseRoute]) -> dict[str, typing.Any]:
|
def get_schema(self, routes: list[BaseRoute]) -> dict[str, typing.Any]:
|
||||||
raise NotImplementedError() # pragma: no cover
|
raise NotImplementedError() # pragma: no cover
|
||||||
|
@ -89,7 +92,7 @@ class BaseSchemaGenerator:
|
||||||
Route("/users/{id:int}", endpoint=get_user, methods=["GET"])
|
Route("/users/{id:int}", endpoint=get_user, methods=["GET"])
|
||||||
Should be represented as `/users/{id}` in the OpenAPI schema.
|
Should be represented as `/users/{id}` in the OpenAPI schema.
|
||||||
"""
|
"""
|
||||||
return re.sub(r":\w+}", "}", path)
|
return _remove_converter_pattern.sub("}", path)
|
||||||
|
|
||||||
def parse_docstring(self, func_or_method: typing.Callable[..., typing.Any]) -> dict[str, typing.Any]:
|
def parse_docstring(self, func_or_method: typing.Callable[..., typing.Any]) -> dict[str, typing.Any]:
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue