diff --git a/.flake8 b/.flake8
index 1b7dcdd1..3f958e89 100644
--- a/.flake8
+++ b/.flake8
@@ -3,9 +3,9 @@ ignore = E203, E266, W503
max-line-length = 88
max-complexity = 18
per-file-ignores =
- neoteroi/web/__init__.py:F401
- neoteroi/web/client/__init__.py:F401
- neoteroi/web/server/__init__.py:F401
+ blacksheep/__init__.py:F401
+ blacksheep/client/__init__.py:F401
+ blacksheep/server/__init__.py:F401
tests/*:E501
itests/*:E501
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 94e4116e..7de3221b 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -17,7 +17,7 @@ on:
- README.md
env:
- PROJECT_NAME: neoteroi
+ PROJECT_NAME: blacksheep
jobs:
windows-validation:
@@ -47,14 +47,14 @@ jobs:
- name: Compile Cython extensions
run: |
- cython neoteroi/web/url.pyx
- cython neoteroi/web/exceptions.pyx
- cython neoteroi/web/headers.pyx
- cython neoteroi/web/cookies.pyx
- cython neoteroi/web/contents.pyx
- cython neoteroi/web/messages.pyx
- cython neoteroi/web/scribe.pyx
- cython neoteroi/web/baseapp.pyx
+ cython blacksheep/url.pyx
+ cython blacksheep/exceptions.pyx
+ cython blacksheep/headers.pyx
+ cython blacksheep/cookies.pyx
+ cython blacksheep/contents.pyx
+ cython blacksheep/messages.pyx
+ cython blacksheep/scribe.pyx
+ cython blacksheep/baseapp.pyx
python setup.py build_ext --inplace
- name: Run tests
@@ -63,7 +63,7 @@ jobs:
- name: Run linters
run: |
- flake8 neoteroi/web
+ flake8 blacksheep
flake8 tests
- name: Test Hypercorn
@@ -125,13 +125,13 @@ jobs:
run: |
echo "Running linters - if build fails here, please be patient! Feel free to ask for assistance."
- flake8 neoteroi/web
+ flake8 blacksheep
flake8 tests
flake8 itests
- isort --check-only neoteroi/web 2>&1
+ isort --check-only blacksheep 2>&1
isort --check-only tests 2>&1
isort --check-only itests 2>&1
- black --check neoteroi/web 2>&1
+ black --check blacksheep 2>&1
black --check tests 2>&1
black --check itests 2>&1
@@ -200,14 +200,14 @@ jobs:
run: |
make clean
- cython neoteroi/web/url.pyx
- cython neoteroi/web/exceptions.pyx
- cython neoteroi/web/headers.pyx
- cython neoteroi/web/cookies.pyx
- cython neoteroi/web/contents.pyx
- cython neoteroi/web/messages.pyx
- cython neoteroi/web/scribe.pyx
- cython neoteroi/web/baseapp.pyx
+ cython blacksheep/url.pyx
+ cython blacksheep/exceptions.pyx
+ cython blacksheep/headers.pyx
+ cython blacksheep/cookies.pyx
+ cython blacksheep/contents.pyx
+ cython blacksheep/messages.pyx
+ cython blacksheep/scribe.pyx
+ cython blacksheep/baseapp.pyx
- name: Build wheels (linux)
if: startsWith(matrix.os, 'ubuntu')
@@ -231,8 +231,8 @@ jobs:
if: |
!startsWith(matrix.os, 'windows')
run: |
- pip install neoteroi/web -f "file:///${GITHUB_WORKSPACE}/dist"
- pip freeze | grep neoteroi/web
+ pip install blacksheep -f "file:///${GITHUB_WORKSPACE}/dist"
+ pip freeze | grep blacksheep
publish:
runs-on: ubuntu-latest
diff --git a/.gitignore b/.gitignore
index 771df416..1a5d1ef9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -112,9 +112,9 @@ tests/out/
*,cover
-neoteroi/web/*.c
-neoteroi/web/*.html
-neoteroi/web/includes/*.html
+blacksheep/*.c
+blacksheep/*.html
+blacksheep/includes/*.html
out/*
# Output of integration tests
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 80595932..be264c95 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,17 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [2.0.0] - ???
-- Renames the web framework package to `neoteroi-web`, to adopt PEP 420 and
- offer a more consistent experience when used with its related libraries.
- The name BlackSheep will still used as project name for some time.
-- Renames the `plugins` namespace to `settings`.
-- Replaces `rodi` with `neoteroi-di`, which includes improvements.
+- Renames the `plugins` namespace to `settings`
+- Upgrades `rodi` to v2, which includes improvements.
- Adds support for alternative implementation of containers for dependency
- injection, removing direct references to `rodi` (now `neoteroi-di`) in most
- of the source code (except for the default service container for the
- `Application` class). Replaces direct dependency on `rodi` classes with
- protocols.
-- Replaces `guardpost` with `neoteroi-auth`, which includes support for
+ injection, using the new `ContainerProtocol` in `rodi`.
+- Upgrades `guardpost` to v1, which includes support for
dependency injection in authentication handlers and authorization requirements.
- Adds support for Binders instantiated using dependency injection. However,
binders are still instantiated once per request handler and are still
diff --git a/MANIFEST.in b/MANIFEST.in
index f427d7e9..7e2451d1 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,9 +1,9 @@
include LICENSE
include README.md
-include neoteroi/web/server/res/*.html
-include neoteroi/web/server/res/*.css
+include blacksheep/server/res/*.html
+include blacksheep/server/res/*.css
include build_info.txt
-recursive-include neoteroi/web *.pyx *.pxd *.pxi *.pyi *.py *.c *.h
+recursive-include blacksheep *.pyx *.pxd *.pxi *.pyi *.py *.c *.h
# Stubs
-include neoteroi/web/py.typed
+include blacksheep/py.typed
diff --git a/Makefile b/Makefile
index 33af9bc0..ba97bb64 100644
--- a/Makefile
+++ b/Makefile
@@ -2,14 +2,14 @@
cyt:
- cython neoteroi/web/url.pyx
- cython neoteroi/web/exceptions.pyx
- cython neoteroi/web/headers.pyx
- cython neoteroi/web/cookies.pyx
- cython neoteroi/web/contents.pyx
- cython neoteroi/web/messages.pyx
- cython neoteroi/web/scribe.pyx
- cython neoteroi/web/baseapp.pyx
+ cython blacksheep/url.pyx
+ cython blacksheep/exceptions.pyx
+ cython blacksheep/headers.pyx
+ cython blacksheep/cookies.pyx
+ cython blacksheep/contents.pyx
+ cython blacksheep/messages.pyx
+ cython blacksheep/scribe.pyx
+ cython blacksheep/baseapp.pyx
compile: cyt
python3 setup.py build_ext --inplace
@@ -18,8 +18,8 @@ compile: cyt
clean:
rm -rf dist/
rm -rf build/
- rm -f neoteroi/web/*.c
- rm -f neoteroi/web/*.so
+ rm -f blacksheep/*.c
+ rm -f blacksheep/*.so
buildext:
@@ -27,14 +27,14 @@ buildext:
annotate:
- cython neoteroi/web/url.pyx -a
- cython neoteroi/web/exceptions.pyx -a
- cython neoteroi/web/headers.pyx -a
- cython neoteroi/web/cookies.pyx -a
- cython neoteroi/web/contents.pyx -a
- cython neoteroi/web/messages.pyx -a
- cython neoteroi/web/scribe.pyx -a
- cython neoteroi/web/baseapp.pyx -a
+ cython blacksheep/url.pyx -a
+ cython blacksheep/exceptions.pyx -a
+ cython blacksheep/headers.pyx -a
+ cython blacksheep/cookies.pyx -a
+ cython blacksheep/contents.pyx -a
+ cython blacksheep/messages.pyx -a
+ cython blacksheep/scribe.pyx -a
+ cython blacksheep/baseapp.pyx -a
artifacts: test
@@ -70,38 +70,38 @@ test-v:
test-cov-unit:
- pytest --cov-report html --cov=neoteroi/web tests
+ pytest --cov-report html --cov=blacksheep tests
test-cov:
- pytest --cov-report html --cov=neoteroi/web --disable-warnings
+ pytest --cov-report html --cov=blacksheep --disable-warnings
lint: check-flake8 check-isort check-black
format:
- @isort neoteroi/web 2>&1
+ @isort blacksheep 2>&1
@isort tests 2>&1
@isort itests 2>&1
- @black neoteroi/web 2>&1
+ @black blacksheep 2>&1
@black tests 2>&1
@black itests 2>&1
check-flake8:
@echo "$(BOLD)Checking flake8$(RESET)"
- @flake8 neoteroi/web 2>&1
+ @flake8 blacksheep 2>&1
@flake8 tests 2>&1
check-isort:
@echo "$(BOLD)Checking isort$(RESET)"
- @isort --check-only neoteroi/web 2>&1
+ @isort --check-only blacksheep 2>&1
@isort --check-only tests 2>&1
@isort --check-only itests 2>&1
check-black: ## Run the black tool in check mode only (won't modify files)
@echo "$(BOLD)Checking black$(RESET)"
- @black --check neoteroi/web 2>&1
+ @black --check blacksheep 2>&1
@black --check tests 2>&1
@black --check itests 2>&1
diff --git a/README.md b/README.md
index ba74655f..b01ddb89 100644
--- a/README.md
+++ b/README.md
@@ -11,26 +11,20 @@ applications with Python. It is inspired by
Core](https://docs.microsoft.com/en-us/aspnet/core/), and the work by [Yury
Selivanov](https://magic.io/blog/uvloop-blazing-fast-python-networking/).
-BlackSheep is the project name of the web framework in Neoteroi. With the
-second version of the framework, the Python package is renamed from `blacksheep` to `neoteroi-web`.
-
```bash
-pip install neoteroi-web
+pip install blacksheep
```
-The first version of the web framework is available as [`blacksheep`](https://pypi.org/project/blacksheep/) and is not going to be _willingly_ modified in non-backward compatible ways (it is stable).
-`neoteroi-web` is currently `alpha` and still subject to change.
-
---
```python
from datetime import datetime
-from neoteroi.web import Application
+from blacksheep import Application
app = Application()
@@ -63,6 +57,7 @@ classifiers. The current list is:
[](https://github.com/robertoprevato/blacksheep)
+
BlackSheep belongs to the category of
[ASGI](https://asgi.readthedocs.io/en/latest/) web frameworks, so it requires
an ASGI HTTP server to run, such as [uvicorn](http://www.uvicorn.org/), or
@@ -77,7 +72,7 @@ To run an application like in the example above, use the methods provided by
the ASGI HTTP Server:
```bash
-# if the web app is defined in a file `server.py`
+# if the BlackSheep app is defined in a file `server.py`
$ uvicorn server:app
```
@@ -93,7 +88,7 @@ here](https://www.neoteroi.dev/blacksheep/requests/).
```python
from dataclasses import dataclass
-from neoteroi.web import Application, FromJSON, FromQuery
+from blacksheep import Application, FromJSON, FromQuery
app = Application()
@@ -180,7 +175,7 @@ async def only_for_authenticated_users():
...
```
-The framework includes:
+Since version `1.2.1`, BlackSheep implements:
* [Built-in support for OpenID Connect authentication](https://www.neoteroi.dev/blacksheep/authentication/#oidc)
* [Built-in support for JWT Bearer authentication](https://www.neoteroi.dev/blacksheep/authentication/#jwt-bearer)
@@ -234,12 +229,14 @@ Refer to the documentation for more details and examples.
* [Anti Forgery validation](https://www.neoteroi.dev/blacksheep/anti-request-forgery) to protect against Cross-Site Request Forgery (XSRF/CSRF) attacks
## Client features
+
BlackSheep includes an HTTP Client.
**Example:**
```python
import asyncio
-from neoteroi.web.client import ClientSession
+
+from blacksheep.client import ClientSession
async def client_example(loop):
@@ -266,4 +263,4 @@ loop.run_until_complete(client_example(loop))
Please refer to the [documentation website](https://www.neoteroi.dev/blacksheep/).
## Communication
-[Community in Gitter](https://gitter.im/Neoteroi/BlackSheep).
+[BlackSheep community in Gitter](https://gitter.im/Neoteroi/BlackSheep).
diff --git a/blacksheep/__init__.py b/blacksheep/__init__.py
new file mode 100644
index 00000000..318f62ff
--- /dev/null
+++ b/blacksheep/__init__.py
@@ -0,0 +1,74 @@
+"""
+Root module of the framework. This module re-exports the most commonly
+used types to reduce the verbosity of the imports statements.
+"""
+__author__ = "Roberto Prevato "
+
+from .contents import Content as Content
+from .contents import FormContent as FormContent
+from .contents import FormPart as FormPart
+from .contents import HTMLContent as HTMLContent
+from .contents import HtmlContent as HtmlContent
+from .contents import JSONContent as JSONContent
+from .contents import MultiPartFormData as MultiPartFormData
+from .contents import StreamedContent as StreamedContent
+from .contents import TextContent as TextContent
+from .contents import parse_www_form as parse_www_form
+from .cookies import Cookie as Cookie
+from .cookies import CookieSameSiteMode as CookieSameSiteMode
+from .cookies import datetime_from_cookie_format as datetime_from_cookie_format
+from .cookies import datetime_to_cookie_format as datetime_to_cookie_format
+from .cookies import parse_cookie as parse_cookie
+from .exceptions import HTTPException as HTTPException
+from .headers import Header as Header
+from .headers import Headers as Headers
+from .messages import Message as Message
+from .messages import Request as Request
+from .messages import Response as Response
+from .server.application import Application as Application
+from .server.authorization import allow_anonymous as allow_anonymous
+from .server.authorization import auth as auth
+from .server.bindings import ClientInfo as ClientInfo
+from .server.bindings import FromBytes as FromBytes
+from .server.bindings import FromCookie as FromCookie
+from .server.bindings import FromFiles as FromFiles
+from .server.bindings import FromForm as FromForm
+from .server.bindings import FromHeader as FromHeader
+from .server.bindings import FromJSON as FromJSON
+from .server.bindings import FromQuery as FromQuery
+from .server.bindings import FromRoute as FromRoute
+from .server.bindings import FromServices as FromServices
+from .server.bindings import FromText as FromText
+from .server.bindings import ServerInfo as ServerInfo
+from .server.responses import ContentDispositionType as ContentDispositionType
+from .server.responses import FileInput as FileInput
+from .server.responses import accepted as accepted
+from .server.responses import bad_request as bad_request
+from .server.responses import created as created
+from .server.responses import file as file
+from .server.responses import forbidden as forbidden
+from .server.responses import html as html
+from .server.responses import json as json
+from .server.responses import moved_permanently as moved_permanently
+from .server.responses import no_content as no_content
+from .server.responses import not_found as not_found
+from .server.responses import not_modified as not_modified
+from .server.responses import ok as ok
+from .server.responses import permanent_redirect as permanent_redirect
+from .server.responses import pretty_json as pretty_json
+from .server.responses import redirect as redirect
+from .server.responses import see_other as see_other
+from .server.responses import status_code as status_code
+from .server.responses import temporary_redirect as temporary_redirect
+from .server.responses import text as text
+from .server.responses import unauthorized as unauthorized
+from .server.routing import Route as Route
+from .server.routing import RouteException as RouteException
+from .server.routing import Router as Router
+from .server.routing import RoutesRegistry as RoutesRegistry
+from .server.websocket import WebSocket as WebSocket
+from .server.websocket import WebSocketDisconnectError as WebSocketDisconnectError
+from .server.websocket import WebSocketError as WebSocketError
+from .server.websocket import WebSocketState as WebSocketState
+from .url import URL as URL
+from .url import InvalidURL as InvalidURL
diff --git a/neoteroi/web/asgi.pyi b/blacksheep/asgi.pyi
similarity index 100%
rename from neoteroi/web/asgi.pyi
rename to blacksheep/asgi.pyi
diff --git a/neoteroi/web/baseapp.pxd b/blacksheep/baseapp.pxd
similarity index 100%
rename from neoteroi/web/baseapp.pxd
rename to blacksheep/baseapp.pxd
diff --git a/neoteroi/web/baseapp.pyi b/blacksheep/baseapp.pyi
similarity index 85%
rename from neoteroi/web/baseapp.pyi
rename to blacksheep/baseapp.pyi
index 2cebf9f0..fc61cf4f 100644
--- a/neoteroi/web/baseapp.pyi
+++ b/blacksheep/baseapp.pyi
@@ -1,10 +1,10 @@
import logging
from typing import Awaitable, Callable, Dict, Optional, Type, TypeVar, Union
-from neoteroi.web.exceptions import HTTPException
-from neoteroi.web.messages import Request, Response
-from neoteroi.web.server.application import Application
-from neoteroi.web.server.routing import RouteMatch, Router
+from blacksheep.exceptions import HTTPException
+from blacksheep.messages import Request, Response
+from blacksheep.server.application import Application
+from blacksheep.server.routing import RouteMatch, Router
ExcT = TypeVar("ExcT", bound=Exception)
diff --git a/neoteroi/web/baseapp.pyx b/blacksheep/baseapp.pyx
similarity index 99%
rename from neoteroi/web/baseapp.pyx
rename to blacksheep/baseapp.pyx
index ea673daf..9ce28cbe 100644
--- a/neoteroi/web/baseapp.pyx
+++ b/blacksheep/baseapp.pyx
@@ -24,7 +24,7 @@ async def common_http_exception_handler(app, Request request, HTTPException http
def get_logger():
- logger = logging.getLogger("neoteroi.web.server")
+ logger = logging.getLogger("blacksheep.server")
logger.setLevel(logging.INFO)
return logger
diff --git a/neoteroi/web/client/__init__.py b/blacksheep/client/__init__.py
similarity index 100%
rename from neoteroi/web/client/__init__.py
rename to blacksheep/client/__init__.py
diff --git a/neoteroi/web/client/connection.py b/blacksheep/client/connection.py
similarity index 99%
rename from neoteroi/web/client/connection.py
rename to blacksheep/client/connection.py
index cbe6da5e..81e6d977 100644
--- a/neoteroi/web/client/connection.py
+++ b/blacksheep/client/connection.py
@@ -7,8 +7,8 @@
import httptools
from httptools import HttpParserCallbackError, HttpParserError
-from neoteroi.web import Content, Request, Response
-from neoteroi.web.scribe import (
+from blacksheep import Content, Request, Response
+from blacksheep.scribe import (
is_small_request,
request_has_body,
write_request,
diff --git a/neoteroi/web/client/cookies.py b/blacksheep/client/cookies.py
similarity index 99%
rename from neoteroi/web/client/cookies.py
rename to blacksheep/client/cookies.py
index 9ac72cb9..bec5ef58 100644
--- a/neoteroi/web/client/cookies.py
+++ b/blacksheep/client/cookies.py
@@ -3,9 +3,9 @@
from ipaddress import ip_address
from typing import Dict, Iterable, Optional, TypeVar
-from neoteroi.web import URL, Cookie
+from blacksheep import URL, Cookie
-client_logger = logging.getLogger("neoteroi.web.client")
+client_logger = logging.getLogger("blacksheep.client")
class InvalidCookie(Exception):
diff --git a/neoteroi/web/client/exceptions.py b/blacksheep/client/exceptions.py
similarity index 98%
rename from neoteroi/web/client/exceptions.py
rename to blacksheep/client/exceptions.py
index df1e6215..d91dd8aa 100644
--- a/neoteroi/web/client/exceptions.py
+++ b/blacksheep/client/exceptions.py
@@ -1,4 +1,4 @@
-from neoteroi.web import URL
+from blacksheep import URL
class InvalidResponseException(Exception):
diff --git a/neoteroi/web/client/pool.py b/blacksheep/client/pool.py
similarity index 97%
rename from neoteroi/web/client/pool.py
rename to blacksheep/client/pool.py
index 2e91644b..994ecedd 100644
--- a/neoteroi/web/client/pool.py
+++ b/blacksheep/client/pool.py
@@ -4,11 +4,11 @@
from ssl import SSLContext
from typing import Dict, Optional, Tuple, Union
-from neoteroi.web.exceptions import InvalidArgument
+from blacksheep.exceptions import InvalidArgument
from .connection import INSECURE_SSLCONTEXT, SECURE_SSLCONTEXT, ClientConnection
-logger = logging.getLogger("neoteroi.web.client")
+logger = logging.getLogger("blacksheep.client")
def get_ssl_context(
diff --git a/neoteroi/web/client/session.py b/blacksheep/client/session.py
similarity index 98%
rename from neoteroi/web/client/session.py
rename to blacksheep/client/session.py
index 15886a81..2b49c79f 100644
--- a/neoteroi/web/client/session.py
+++ b/blacksheep/client/session.py
@@ -4,9 +4,9 @@
from typing import Any, AnyStr, Callable, Dict, List, Optional, Tuple, Type, Union, cast
from urllib.parse import urlencode
-from neoteroi.web import URL, Content, InvalidURL, Request, Response
-from neoteroi.web.middlewares import get_middlewares_chain
-from neoteroi.web.utils.aio import get_running_loop
+from blacksheep import URL, Content, InvalidURL, Request, Response
+from blacksheep.middlewares import get_middlewares_chain
+from blacksheep.utils.aio import get_running_loop
from .connection import ConnectionClosedError
from .cookies import CookieJar, cookies_middleware
diff --git a/neoteroi/web/common/__init__.py b/blacksheep/common/__init__.py
similarity index 100%
rename from neoteroi/web/common/__init__.py
rename to blacksheep/common/__init__.py
diff --git a/neoteroi/web/common/files/__init__.py b/blacksheep/common/files/__init__.py
similarity index 100%
rename from neoteroi/web/common/files/__init__.py
rename to blacksheep/common/files/__init__.py
diff --git a/neoteroi/web/common/files/asyncfs.py b/blacksheep/common/files/asyncfs.py
similarity index 98%
rename from neoteroi/web/common/files/asyncfs.py
rename to blacksheep/common/files/asyncfs.py
index 2d4b1766..2f339fb5 100644
--- a/neoteroi/web/common/files/asyncfs.py
+++ b/blacksheep/common/files/asyncfs.py
@@ -2,7 +2,7 @@
from concurrent.futures.thread import ThreadPoolExecutor
from typing import IO, Any, AnyStr, AsyncIterable, Callable, Optional, Union
-from neoteroi.web.utils.aio import get_running_loop
+from blacksheep.utils.aio import get_running_loop
class PoolClient:
diff --git a/neoteroi/web/common/files/info.py b/blacksheep/common/files/info.py
similarity index 100%
rename from neoteroi/web/common/files/info.py
rename to blacksheep/common/files/info.py
diff --git a/neoteroi/web/common/files/pathsutils.py b/blacksheep/common/files/pathsutils.py
similarity index 100%
rename from neoteroi/web/common/files/pathsutils.py
rename to blacksheep/common/files/pathsutils.py
diff --git a/neoteroi/web/contents.pxd b/blacksheep/contents.pxd
similarity index 100%
rename from neoteroi/web/contents.pxd
rename to blacksheep/contents.pxd
diff --git a/neoteroi/web/contents.pyi b/blacksheep/contents.pyi
similarity index 100%
rename from neoteroi/web/contents.pyi
rename to blacksheep/contents.pyi
diff --git a/neoteroi/web/contents.pyx b/blacksheep/contents.pyx
similarity index 99%
rename from neoteroi/web/contents.pyx
rename to blacksheep/contents.pyx
index bb9bcfb4..7ac931e4 100644
--- a/neoteroi/web/contents.pyx
+++ b/blacksheep/contents.pyx
@@ -5,7 +5,7 @@ from inspect import isasyncgenfunction
from typing import Dict, List, Optional, Tuple, Union
from urllib.parse import parse_qsl, quote_plus
-from neoteroi.web.settings.json import json_settings
+from blacksheep.settings.json import json_settings
from .exceptions cimport MessageAborted
diff --git a/neoteroi/web/cookies.pxd b/blacksheep/cookies.pxd
similarity index 100%
rename from neoteroi/web/cookies.pxd
rename to blacksheep/cookies.pxd
diff --git a/neoteroi/web/cookies.pyi b/blacksheep/cookies.pyi
similarity index 100%
rename from neoteroi/web/cookies.pyi
rename to blacksheep/cookies.pyi
diff --git a/neoteroi/web/cookies.pyx b/blacksheep/cookies.pyx
similarity index 100%
rename from neoteroi/web/cookies.pyx
rename to blacksheep/cookies.pyx
diff --git a/neoteroi/web/exceptions.pxd b/blacksheep/exceptions.pxd
similarity index 100%
rename from neoteroi/web/exceptions.pxd
rename to blacksheep/exceptions.pxd
diff --git a/neoteroi/web/exceptions.pyi b/blacksheep/exceptions.pyi
similarity index 100%
rename from neoteroi/web/exceptions.pyi
rename to blacksheep/exceptions.pyi
diff --git a/neoteroi/web/exceptions.pyx b/blacksheep/exceptions.pyx
similarity index 100%
rename from neoteroi/web/exceptions.pyx
rename to blacksheep/exceptions.pyx
diff --git a/neoteroi/web/headers.pxd b/blacksheep/headers.pxd
similarity index 100%
rename from neoteroi/web/headers.pxd
rename to blacksheep/headers.pxd
diff --git a/neoteroi/web/headers.pyi b/blacksheep/headers.pyi
similarity index 100%
rename from neoteroi/web/headers.pyi
rename to blacksheep/headers.pyi
diff --git a/neoteroi/web/headers.pyx b/blacksheep/headers.pyx
similarity index 100%
rename from neoteroi/web/headers.pyx
rename to blacksheep/headers.pyx
diff --git a/blacksheep/includes/consts.pxi b/blacksheep/includes/consts.pxi
new file mode 100644
index 00000000..3ba36ebd
--- /dev/null
+++ b/blacksheep/includes/consts.pxi
@@ -0,0 +1,6 @@
+DEF MAX_RESPONSE_CHUNK_SIZE = 61440 # 64kb
+DEF MAX_REQUEST_HEADERS_COUNT = 80
+DEF MAX_REQUEST_HEADER_SIZE = 8192 # 8kb
+
+# 61440 # 64kb
+# 16384
\ No newline at end of file
diff --git a/neoteroi/web/messages.pxd b/blacksheep/messages.pxd
similarity index 100%
rename from neoteroi/web/messages.pxd
rename to blacksheep/messages.pxd
diff --git a/neoteroi/web/messages.pyi b/blacksheep/messages.pyi
similarity index 99%
rename from neoteroi/web/messages.pyi
rename to blacksheep/messages.pyi
index b81b3abb..d8614127 100644
--- a/neoteroi/web/messages.pyi
+++ b/blacksheep/messages.pyi
@@ -1,6 +1,6 @@
from typing import Any, Callable, Dict, Generator, List, Optional, Union
-from neoteroi.auth import Identity
+from guardpost import Identity
from .asgi import ASGIScopeInterface
from .contents import Content, FormPart
diff --git a/neoteroi/web/messages.pyx b/blacksheep/messages.pyx
similarity index 99%
rename from neoteroi/web/messages.pyx
rename to blacksheep/messages.pyx
index 642e2b46..fb32b796 100644
--- a/neoteroi/web/messages.pyx
+++ b/blacksheep/messages.pyx
@@ -9,9 +9,9 @@ try:
except ImportError:
import chardet
-from neoteroi.web.multipart import parse_multipart
-from neoteroi.web.sessions import Session
-from neoteroi.web.settings.json import json_settings
+from blacksheep.multipart import parse_multipart
+from blacksheep.sessions import Session
+from blacksheep.settings.json import json_settings
from .contents cimport Content, multiparts_to_dictionary, parse_www_form_urlencoded
from .cookies cimport Cookie, parse_cookie, split_value, write_cookie_for_response
diff --git a/neoteroi/web/middlewares.py b/blacksheep/middlewares.py
similarity index 89%
rename from neoteroi/web/middlewares.py
rename to blacksheep/middlewares.py
index ba4ff071..e1978196 100644
--- a/neoteroi/web/middlewares.py
+++ b/blacksheep/middlewares.py
@@ -1,4 +1,4 @@
-from neoteroi.web.normalization import copy_special_attributes
+from blacksheep.normalization import copy_special_attributes
def middleware_partial(handler, next_handler):
diff --git a/neoteroi/web/multipart.py b/blacksheep/multipart.py
similarity index 98%
rename from neoteroi/web/multipart.py
rename to blacksheep/multipart.py
index 82f21ddf..be13449c 100644
--- a/neoteroi/web/multipart.py
+++ b/blacksheep/multipart.py
@@ -1,6 +1,6 @@
from typing import Dict, Generator, Iterable, Optional, Tuple
-from neoteroi.web.contents import FormPart
+from blacksheep.contents import FormPart
def get_boundary_from_header(value: bytes) -> bytes:
diff --git a/neoteroi/web/normalization.py b/blacksheep/normalization.py
similarity index 100%
rename from neoteroi/web/normalization.py
rename to blacksheep/normalization.py
diff --git a/neoteroi/web/py.typed b/blacksheep/py.typed
similarity index 100%
rename from neoteroi/web/py.typed
rename to blacksheep/py.typed
diff --git a/neoteroi/web/ranges.py b/blacksheep/ranges.py
similarity index 100%
rename from neoteroi/web/ranges.py
rename to blacksheep/ranges.py
diff --git a/neoteroi/web/scribe.pxd b/blacksheep/scribe.pxd
similarity index 100%
rename from neoteroi/web/scribe.pxd
rename to blacksheep/scribe.pxd
diff --git a/neoteroi/web/scribe.pyi b/blacksheep/scribe.pyi
similarity index 84%
rename from neoteroi/web/scribe.pyi
rename to blacksheep/scribe.pyi
index 7ab3d32d..c82eff26 100644
--- a/neoteroi/web/scribe.pyi
+++ b/blacksheep/scribe.pyi
@@ -1,8 +1,8 @@
from typing import AsyncIterable, Callable
-from neoteroi.web.contents import Content
-from neoteroi.web.cookies import Cookie
-from neoteroi.web.messages import Request, Response
+from blacksheep.contents import Content
+from blacksheep.cookies import Cookie
+from blacksheep.messages import Request, Response
def get_status_line(status: int) -> bytes: ...
def is_small_request(request: Request) -> bool: ...
diff --git a/neoteroi/web/scribe.pyx b/blacksheep/scribe.pyx
similarity index 100%
rename from neoteroi/web/scribe.pyx
rename to blacksheep/scribe.pyx
diff --git a/neoteroi/web/server/__init__.py b/blacksheep/server/__init__.py
similarity index 100%
rename from neoteroi/web/server/__init__.py
rename to blacksheep/server/__init__.py
diff --git a/neoteroi/web/server/application.py b/blacksheep/server/application.py
similarity index 90%
rename from neoteroi/web/server/application.py
rename to blacksheep/server/application.py
index 8fdfa8ce..860e4972 100644
--- a/neoteroi/web/server/application.py
+++ b/blacksheep/server/application.py
@@ -14,52 +14,53 @@
Union,
)
-from itsdangerous import Serializer
-
-from neoteroi.auth import (
+from guardpost import (
AuthenticationStrategy,
AuthorizationStrategy,
Policy,
UnauthorizedError,
)
-from neoteroi.auth.common import AuthenticatedRequirement
-from neoteroi.di import ContainerProtocol
-from neoteroi.web.baseapp import BaseApplication, handle_not_found
-from neoteroi.web.common.files.asyncfs import FilesHandler
-from neoteroi.web.contents import ASGIContent
-from neoteroi.web.exceptions import HTTPException
-from neoteroi.web.messages import Request, Response
-from neoteroi.web.middlewares import get_middlewares_chain
-from neoteroi.web.scribe import send_asgi_response
-from neoteroi.web.server.asgi import get_request_url_from_scope
-from neoteroi.web.server.authentication import (
+from guardpost.common import AuthenticatedRequirement
+from itsdangerous import Serializer
+from rodi import ContainerProtocol
+
+from blacksheep.baseapp import BaseApplication, handle_not_found
+from blacksheep.common.files.asyncfs import FilesHandler
+from blacksheep.contents import ASGIContent
+from blacksheep.exceptions import HTTPException
+from blacksheep.messages import Request, Response
+from blacksheep.middlewares import get_middlewares_chain
+from blacksheep.scribe import send_asgi_response
+from blacksheep.server.asgi import get_request_url_from_scope
+from blacksheep.server.authentication import (
AuthenticateChallenge,
get_authentication_middleware,
handle_authentication_challenge,
)
-from neoteroi.web.server.authorization import (
+from blacksheep.server.authorization import (
AuthorizationWithoutAuthenticationError,
get_authorization_middleware,
handle_unauthorized,
)
-from neoteroi.web.server.bindings import ControllerParameter
-from neoteroi.web.server.controllers import router as controllers_router
-from neoteroi.web.server.cors import CORSPolicy, CORSStrategy, get_cors_middleware
-from neoteroi.web.server.env import EnvironmentSettings
-from neoteroi.web.server.errors import ServerErrorDetailsHandler
-from neoteroi.web.server.files.dynamic import serve_files_dynamic
-from neoteroi.web.server.normalization import normalize_handler, normalize_middleware
-from neoteroi.web.server.responses import _ensure_bytes
-from neoteroi.web.server.routing import (
+from blacksheep.server.bindings import ControllerParameter
+from blacksheep.server.controllers import router as controllers_router
+from blacksheep.server.cors import CORSPolicy, CORSStrategy, get_cors_middleware
+from blacksheep.server.env import EnvironmentSettings
+from blacksheep.server.errors import ServerErrorDetailsHandler
+from blacksheep.server.files import ServeFilesOptions
+from blacksheep.server.files.dynamic import serve_files_dynamic
+from blacksheep.server.normalization import normalize_handler, normalize_middleware
+from blacksheep.server.responses import _ensure_bytes
+from blacksheep.server.routing import (
MountRegistry,
RegisteredRoute,
Router,
RoutesRegistry,
)
-from neoteroi.web.server.websocket import WebSocket
-from neoteroi.web.sessions import SessionMiddleware, SessionSerializer
-from neoteroi.web.settings.di import di_settings
-from neoteroi.web.utils import ensure_bytes, join_fragments
+from blacksheep.server.websocket import WebSocket
+from blacksheep.sessions import SessionMiddleware, SessionSerializer
+from blacksheep.settings.di import di_settings
+from blacksheep.utils import ensure_bytes, join_fragments
def get_default_headers_middleware(
@@ -224,14 +225,14 @@ def mount(self, path: str, app: Callable) -> None:
that starts with the mount path, it is handled by the mounted app (the mount
path is stripped from the final URL path received by the child application).
- If the child application is a Neoteroi application, it requires handling of
- its lifecycle events. This is automatic, unless the environment variable
+ If the child application is a BlackSheep application, it requires handling of
+ its lifecycle events. This can be automatic, if the environment variable
- APP_MOUNT_AUTO_EVENTS is set to "0" or "false" (case insensitive)
+ APP_MOUNT_AUTO_EVENTS is set to "1" or "true" (case insensitive)
- or explicitly disabled, if the parent app's is configured this way:
+ or explicitly enabled, if the parent app's is configured this way:
- parent_app.mount_registry.auto_events = False
+ parent_app.mount_registry.auto_events = True
"""
if app is self:
raise TypeError("Cannot mount an application into itself")
@@ -434,8 +435,7 @@ def exception_handler(
self, exception: Union[int, Type[Exception]]
) -> Callable[..., Any]:
"""
- Registers an exception handler function in the application exception handlers
- dictionary.
+ Registers an exception handler function in the application exception handler.
"""
def decorator(f):
@@ -475,6 +475,25 @@ def serve_files(
response would be otherwise 404 Not Found; e.g. use this to serve SPA that
use HTML5 History API for client side routing.
"""
+ if isinstance(source_folder, ServeFilesOptions):
+ # deprecated class, will be removed in the next version
+ from typing import cast
+
+ deprecated_arg = cast(ServeFilesOptions, source_folder)
+ deprecated_arg.validate()
+ serve_files_dynamic(
+ self.router,
+ self.files_handler,
+ str(deprecated_arg.source_folder),
+ discovery=deprecated_arg.discovery,
+ cache_time=deprecated_arg.cache_time,
+ extensions=deprecated_arg.extensions,
+ root_path=deprecated_arg.root_path,
+ index_document=deprecated_arg.index_document,
+ fallback_document=deprecated_arg.fallback_document,
+ anonymous_access=deprecated_arg.allow_anonymous,
+ )
+ return
serve_files_dynamic(
self.router,
self.files_handler,
diff --git a/neoteroi/web/server/asgi.py b/blacksheep/server/asgi.py
similarity index 85%
rename from neoteroi/web/server/asgi.py
rename to blacksheep/server/asgi.py
index 815b0622..5b6bac4c 100644
--- a/neoteroi/web/server/asgi.py
+++ b/blacksheep/server/asgi.py
@@ -1,5 +1,5 @@
-from neoteroi.web.contents import ASGIContent
-from neoteroi.web.messages import Request
+from blacksheep.contents import ASGIContent
+from blacksheep.messages import Request
def get_request_url_from_scope(
@@ -15,10 +15,7 @@ def get_request_url_from_scope(
Do not use this method for logic that must generate full request URL, since it
doesn't handle Forward and X-Forwarded* headers - use instead:
- > from neoteroi.web.messages import (
- get_absolute_url_to_path,
- get_request_absolute_url,
- )
+ > from blacksheep.messages import get_absolute_url_to_path, get_request_absolute_url
"""
try:
path = scope["path"]
@@ -53,10 +50,7 @@ def get_request_url(request: Request) -> str:
Do not use this method for logic that must generate full request URL, since it
doesn't handle Forward and X-Forwarded* headers - use instead:
- > from neoteroi.web.messages import (
- get_absolute_url_to_path,
- get_request_absolute_url,
- )
+ > from blacksheep.messages import get_absolute_url_to_path, get_request_absolute_url
"""
return get_request_url_from_scope(request.scope)
@@ -65,7 +59,7 @@ def incoming_request(scope, receive=None) -> Request:
"""
Function used to simulate incoming requests from an ASGI scope.
This function is intentionally not used in
- `neoteroi.web.server.application.Application`.
+ `blacksheep.server.application.Application`.
"""
request = Request.incoming(
scope["method"],
diff --git a/neoteroi/web/server/authentication/__init__.py b/blacksheep/server/authentication/__init__.py
similarity index 91%
rename from neoteroi/web/server/authentication/__init__.py
rename to blacksheep/server/authentication/__init__.py
index da070e61..a1e045d6 100644
--- a/neoteroi/web/server/authentication/__init__.py
+++ b/blacksheep/server/authentication/__init__.py
@@ -1,11 +1,8 @@
from typing import Dict, Optional, Tuple
-from neoteroi.auth import (
- AuthenticationHandler,
- AuthenticationStrategy,
- AuthorizationError,
-)
-from neoteroi.web import Response, TextContent
+from guardpost import AuthenticationHandler, AuthenticationStrategy, AuthorizationError
+
+from blacksheep import Response, TextContent
__all__ = (
"AuthenticationStrategy",
diff --git a/neoteroi/web/server/authentication/cookie.py b/blacksheep/server/authentication/cookie.py
similarity index 90%
rename from neoteroi/web/server/authentication/cookie.py
rename to blacksheep/server/authentication/cookie.py
index e7ae62ce..774c98fb 100644
--- a/neoteroi/web/server/authentication/cookie.py
+++ b/blacksheep/server/authentication/cookie.py
@@ -1,15 +1,15 @@
from datetime import datetime
from typing import Any, Optional, Sequence
+from guardpost import AuthenticationHandler, Identity
from itsdangerous import Serializer
from itsdangerous.exc import BadSignature
-from neoteroi.auth import AuthenticationHandler, Identity
-from neoteroi.web.baseapp import get_logger
-from neoteroi.web.cookies import Cookie
-from neoteroi.web.messages import Request, Response
-from neoteroi.web.server.dataprotection import get_serializer
-from neoteroi.web.utils import ensure_str
+from blacksheep.baseapp import get_logger
+from blacksheep.cookies import Cookie
+from blacksheep.messages import Request, Response
+from blacksheep.server.dataprotection import get_serializer
+from blacksheep.utils import ensure_str
class CookieAuthentication(AuthenticationHandler):
@@ -65,9 +65,10 @@ def set_cookie(self, data: Any, response: Response, secure: bool = False) -> Non
Anything that can be serialized by an `itsdangerous.Serializer`, a
dictionary in the most common scenario.
response : Response
- The instance of `Response` that will include the cookie for the client.
+ The instance of blacksheep `Response` that will include the cookie for the
+ client.
secure : bool, optional
- Whether the set cookie should have secure flag, by default False.
+ Whether the set cookie should have secure flag, by default False
"""
value = self.serializer.dumps(data)
diff --git a/neoteroi/web/server/authentication/jwt.py b/blacksheep/server/authentication/jwt.py
similarity index 95%
rename from neoteroi/web/server/authentication/jwt.py
rename to blacksheep/server/authentication/jwt.py
index bde90f5a..2d1ea5f0 100644
--- a/neoteroi/web/server/authentication/jwt.py
+++ b/blacksheep/server/authentication/jwt.py
@@ -1,12 +1,12 @@
from typing import Optional, Sequence
+from guardpost import AuthenticationHandler, Identity
+from guardpost.jwks import KeysProvider
+from guardpost.jwts import InvalidAccessToken, JWTValidator
from jwt.exceptions import InvalidTokenError
-from neoteroi.auth import AuthenticationHandler, Identity
-from neoteroi.auth.jwks import KeysProvider
-from neoteroi.auth.jwts import InvalidAccessToken, JWTValidator
-from neoteroi.web.baseapp import get_logger
-from neoteroi.web.messages import Request
+from blacksheep.baseapp import get_logger
+from blacksheep.messages import Request
class JWTBearerAuthentication(AuthenticationHandler):
diff --git a/neoteroi/web/server/authentication/oidc.py b/blacksheep/server/authentication/oidc.py
similarity index 96%
rename from neoteroi/web/server/authentication/oidc.py
rename to blacksheep/server/authentication/oidc.py
index 3b2be522..43d67a6b 100644
--- a/neoteroi/web/server/authentication/oidc.py
+++ b/blacksheep/server/authentication/oidc.py
@@ -10,26 +10,26 @@
from typing import Any, AnyStr, Awaitable, Callable, Dict, Optional, Sequence
from urllib.parse import urlencode
+from guardpost import UnauthorizedError
+from guardpost.jwts import InvalidAccessToken, JWTValidator
from itsdangerous import Serializer
from itsdangerous.exc import BadSignature
from jwt import InvalidTokenError
-from neoteroi.auth import UnauthorizedError
-from neoteroi.auth.jwts import InvalidAccessToken, JWTValidator
-from neoteroi.web.cookies import Cookie
-from neoteroi.web.exceptions import BadRequest, Unauthorized
-from neoteroi.web.messages import Request, Response, get_absolute_url_to_path
-from neoteroi.web.server.application import Application, ApplicationEvent
-from neoteroi.web.server.authentication.cookie import CookieAuthentication
-from neoteroi.web.server.authorization import allow_anonymous
-from neoteroi.web.server.dataprotection import generate_secret, get_serializer
-from neoteroi.web.server.responses import accepted, redirect
-from neoteroi.web.utils import ensure_str
-from neoteroi.web.utils.aio import FailedRequestError, HTTPHandler
+from blacksheep.cookies import Cookie
+from blacksheep.exceptions import BadRequest, Unauthorized
+from blacksheep.messages import Request, Response, get_absolute_url_to_path
+from blacksheep.server.application import Application, ApplicationEvent
+from blacksheep.server.authentication.cookie import CookieAuthentication
+from blacksheep.server.authorization import allow_anonymous
+from blacksheep.server.dataprotection import generate_secret, get_serializer
+from blacksheep.server.responses import accepted, redirect
+from blacksheep.utils import ensure_str
+from blacksheep.utils.aio import FailedRequestError, HTTPHandler
def get_logger() -> logging.Logger:
- logger = logging.getLogger("neoteroi.web.oidc")
+ logger = logging.getLogger("blacksheep.oidc")
logger.setLevel(logging.INFO)
return logger
diff --git a/neoteroi/web/server/authorization/__init__.py b/blacksheep/server/authorization/__init__.py
similarity index 97%
rename from neoteroi/web/server/authorization/__init__.py
rename to blacksheep/server/authorization/__init__.py
index fce2967c..eb9ae076 100644
--- a/neoteroi/web/server/authorization/__init__.py
+++ b/blacksheep/server/authorization/__init__.py
@@ -1,12 +1,13 @@
from typing import Any, Awaitable, Callable, Optional, Sequence, Tuple
-from neoteroi.auth.authorization import (
+from guardpost.authorization import (
AuthorizationStrategy,
Policy,
Requirement,
UnauthorizedError,
)
-from neoteroi.web import Request, Response, TextContent
+
+from blacksheep import Request, Response, TextContent
__all__ = (
"auth",
diff --git a/neoteroi/web/server/bindings.py b/blacksheep/server/bindings.py
similarity index 98%
rename from neoteroi/web/server/bindings.py
rename to blacksheep/server/bindings.py
index 0dc795f9..eff3a9d3 100644
--- a/neoteroi/web/server/bindings.py
+++ b/blacksheep/server/bindings.py
@@ -30,14 +30,14 @@
from uuid import UUID
from dateutil.parser import parse as dateutil_parser
+from guardpost import Identity
+from rodi import CannotResolveTypeException, ContainerProtocol
-from neoteroi.auth import Identity
-from neoteroi.di import CannotResolveTypeException, ContainerProtocol
-from neoteroi.web import Request
-from neoteroi.web.contents import FormPart
-from neoteroi.web.exceptions import BadRequest
-from neoteroi.web.server.websocket import WebSocket
-from neoteroi.web.url import URL
+from blacksheep import Request
+from blacksheep.contents import FormPart
+from blacksheep.exceptions import BadRequest
+from blacksheep.server.websocket import WebSocket
+from blacksheep.url import URL
T = TypeVar("T")
TypeOrName = Union[Type, str]
@@ -448,7 +448,7 @@ def _get_default_converter_for_iterable(self, expected_type):
item_type = self.generic_iterable_annotation_item_type(expected_type)
if isinstance(item_type, ForwardRef): # pragma: no cover
- from neoteroi.web.server.normalization import (
+ from blacksheep.server.normalization import (
UnsupportedForwardRefInSignatureError,
)
@@ -809,7 +809,7 @@ class ControllerBinder(ServiceBinder):
Binder used to activate an instance of Controller. This binder is applied
automatically by the application
object at startup, as type annotation, for handlers configured on classes
- inheriting `neoteroi.web.server.Controller`.
+ inheriting `blacksheep.server.Controller`.
If used manually, it causes several controllers to be instantiated and
injected into request handlers.
diff --git a/neoteroi/web/server/controllers.py b/blacksheep/server/controllers.py
similarity index 98%
rename from neoteroi/web/server/controllers.py
rename to blacksheep/server/controllers.py
index f8b9f7b5..c9576d42 100644
--- a/neoteroi/web/server/controllers.py
+++ b/blacksheep/server/controllers.py
@@ -2,8 +2,8 @@
from io import BytesIO
from typing import Any, AsyncIterable, Callable, Optional, Union
-from neoteroi.web import Request, Response
-from neoteroi.web.server.responses import (
+from blacksheep import Request, Response
+from blacksheep.server.responses import (
ContentDispositionType,
MessageType,
accepted,
@@ -28,8 +28,8 @@
view,
view_async,
)
-from neoteroi.web.server.routing import RoutesRegistry
-from neoteroi.web.utils import AnyStr, join_fragments
+from blacksheep.server.routing import RoutesRegistry
+from blacksheep.utils import AnyStr, join_fragments
# singleton router used to store initial configuration,
# before the application starts
diff --git a/neoteroi/web/server/cors.py b/blacksheep/server/cors.py
similarity index 97%
rename from neoteroi/web/server/cors.py
rename to blacksheep/server/cors.py
index 1b01fc7b..43ea76af 100644
--- a/neoteroi/web/server/cors.py
+++ b/blacksheep/server/cors.py
@@ -2,10 +2,9 @@
from functools import lru_cache
from typing import Any, Awaitable, Callable, Dict, FrozenSet, Iterable, Optional, Union
-from neoteroi.web.baseapp import BaseApplication
-from neoteroi.web.messages import Request, Response
-from neoteroi.web.server.routing import Route, Router
-from neoteroi.web.server.websocket import WebSocket
+from blacksheep.baseapp import BaseApplication
+from blacksheep.messages import Request, Response
+from blacksheep.server.routing import Route, Router
from .responses import not_found, ok, status_code
@@ -244,9 +243,6 @@ def get_cors_middleware(
strategy: CORSStrategy,
) -> Callable[[Request, Callable[..., Any]], Awaitable[Response]]:
async def cors_middleware(request: Request, handler):
- if isinstance(request, WebSocket):
- return await handler(request)
-
origin = request.get_first_header(b"Origin")
if not origin:
diff --git a/neoteroi/web/server/csrf.py b/blacksheep/server/csrf.py
similarity index 96%
rename from neoteroi/web/server/csrf.py
rename to blacksheep/server/csrf.py
index 07de9d30..c9d0a6d2 100644
--- a/neoteroi/web/server/csrf.py
+++ b/blacksheep/server/csrf.py
@@ -4,14 +4,14 @@
from itsdangerous import Serializer
from itsdangerous.exc import BadSignature
-from neoteroi.web.baseapp import get_logger
-from neoteroi.web.cookies import Cookie
-from neoteroi.web.exceptions import Unauthorized
-from neoteroi.web.messages import Request, Response
-from neoteroi.web.server.application import Application
-from neoteroi.web.server.dataprotection import generate_secret, get_serializer
-from neoteroi.web.server.security import SecurityPolicyHandler
-from neoteroi.web.settings.html import html_settings
+from blacksheep.baseapp import get_logger
+from blacksheep.cookies import Cookie
+from blacksheep.exceptions import Unauthorized
+from blacksheep.messages import Request, Response
+from blacksheep.server.application import Application
+from blacksheep.server.dataprotection import generate_secret, get_serializer
+from blacksheep.server.security import SecurityPolicyHandler
+from blacksheep.settings.html import html_settings
class AntiForgeryTokenError(Unauthorized):
@@ -161,7 +161,7 @@ def set_cookie(self, response: Response, value: str, secure: bool = False) -> No
Anything that can be serialized by an `itsdangerous.Serializer`, a
dictionary in the most common scenario.
response : Response
- The instance of neoteroi.web `Response` that will include the cookie for the
+ The instance of blacksheep `Response` that will include the cookie for the
client.
secure : bool, optional
Whether the set cookie should have secure flag, by default False
diff --git a/neoteroi/web/server/dataprotection.py b/blacksheep/server/dataprotection.py
similarity index 92%
rename from neoteroi/web/server/dataprotection.py
rename to blacksheep/server/dataprotection.py
index be47b0bf..e461b20e 100644
--- a/neoteroi/web/server/dataprotection.py
+++ b/blacksheep/server/dataprotection.py
@@ -6,7 +6,7 @@
from itsdangerous import Serializer
from itsdangerous.url_safe import URLSafeSerializer
-from neoteroi.web.baseapp import get_logger
+from blacksheep.baseapp import get_logger
logger = get_logger()
@@ -23,7 +23,7 @@ def get_keys() -> List[str]:
# APP_SECRET_2="***"
# APP_SECRET_3="***"
app_secrets = []
- env_var_key_prefix = os.environ.get("NEOTEROI_SECRET_PREFIX", "APP_SECRET")
+ env_var_key_prefix = os.environ.get("BLACKSHEEP_SECRET_PREFIX", "APP_SECRET")
for key, value in os.environ.items():
if key.startswith(env_var_key_prefix) or key.startswith(
diff --git a/neoteroi/web/server/di.py b/blacksheep/server/di.py
similarity index 86%
rename from neoteroi/web/server/di.py
rename to blacksheep/server/di.py
index d0c6ed72..bfe2a9b1 100644
--- a/neoteroi/web/server/di.py
+++ b/blacksheep/server/di.py
@@ -1,10 +1,11 @@
from typing import TYPE_CHECKING, Awaitable, Callable
-from neoteroi.di import ActivationScope, Container
-from neoteroi.web.messages import Request, Response
+from rodi import ActivationScope, Container
+
+from blacksheep.messages import Request, Response
if TYPE_CHECKING:
- from neoteroi.web.server.application import Application
+ from blacksheep.server.application import Application
async def di_scope_middleware(
@@ -35,13 +36,13 @@ def register_http_context(app: "Application"):
"""
Makes the `Request` object accessible through dependency injection for the
application container.
- This method requires using `neoteroi-di` as solution for dependency injection, since
+ This method requires using `rodi` as solution for dependency injection, since
other implementations might not support scoped services and factories using the
activation scope.
This is not a recommended pattern, but it might be desired in certain situations.
"""
- assert isinstance(app.services, Container), "This method requires neoteroi-di."
+ assert isinstance(app.services, Container), "This method requires rodi."
if di_scope_middleware not in app.middlewares:
diff --git a/neoteroi/web/server/env.py b/blacksheep/server/env.py
similarity index 95%
rename from neoteroi/web/server/env.py
rename to blacksheep/server/env.py
index e4dda1e7..4adc2a3b 100644
--- a/neoteroi/web/server/env.py
+++ b/blacksheep/server/env.py
@@ -13,4 +13,4 @@ class EnvironmentSettings:
def __init__(self) -> None:
self.show_error_details = truthy(os.environ.get("APP_SHOW_ERROR_DETAILS", ""))
- self.mount_auto_events = truthy(os.environ.get("APP_MOUNT_AUTO_EVENTS", "1"))
+ self.mount_auto_events = truthy(os.environ.get("APP_MOUNT_AUTO_EVENTS", ""))
diff --git a/neoteroi/web/server/errors.py b/blacksheep/server/errors.py
similarity index 87%
rename from neoteroi/web/server/errors.py
rename to blacksheep/server/errors.py
index 44a8ade0..0453a113 100644
--- a/neoteroi/web/server/errors.py
+++ b/blacksheep/server/errors.py
@@ -1,10 +1,10 @@
import html
import traceback
-from neoteroi.web.contents import HTMLContent
-from neoteroi.web.messages import Request, Response
-from neoteroi.web.server.asgi import get_request_url
-from neoteroi.web.server.resources import get_resource_file_content
+from blacksheep.contents import HTMLContent
+from blacksheep.messages import Request, Response
+from blacksheep.server.asgi import get_request_url
+from blacksheep.server.resources import get_resource_file_content
def _load_error_page_template() -> str:
diff --git a/neoteroi/web/server/files/__init__.py b/blacksheep/server/files/__init__.py
similarity index 71%
rename from neoteroi/web/server/files/__init__.py
rename to blacksheep/server/files/__init__.py
index 13526aac..e28c030b 100644
--- a/neoteroi/web/server/files/__init__.py
+++ b/blacksheep/server/files/__init__.py
@@ -1,13 +1,13 @@
import uuid
from pathlib import Path
-from typing import AsyncIterable, Callable, Optional, Set
+from typing import AsyncIterable, Callable, Optional, Set, Union
-from neoteroi.web import Request, Response, StreamedContent
-from neoteroi.web.common.files.asyncfs import FilesHandler
-from neoteroi.web.common.files.info import FileInfo
-from neoteroi.web.common.files.pathsutils import get_mime_type_from_name
-from neoteroi.web.exceptions import BadRequest, InvalidArgument, RangeNotSatisfiable
-from neoteroi.web.ranges import InvalidRangeValue, Range, RangePart
+from blacksheep import Request, Response, StreamedContent
+from blacksheep.common.files.asyncfs import FilesHandler
+from blacksheep.common.files.info import FileInfo
+from blacksheep.common.files.pathsutils import get_mime_type_from_name
+from blacksheep.exceptions import BadRequest, InvalidArgument, RangeNotSatisfiable
+from blacksheep.ranges import InvalidRangeValue, Range, RangePart
def _get_content_range_value(part: RangePart, file_size: int) -> bytes:
@@ -184,6 +184,80 @@ def validate_source_path(source_folder: str) -> None:
raise InvalidArgument("The given root path is not a directory.")
+class ServeFilesOptions:
+
+ __slots__ = (
+ "source_folder",
+ "extensions",
+ "discovery",
+ "cache_time",
+ "root_path",
+ "allow_anonymous",
+ "index_document",
+ "fallback_document",
+ )
+
+ def __init__(
+ self,
+ source_folder: Union[str, Path],
+ *,
+ extensions: Optional[Set[str]] = None,
+ discovery: bool = False,
+ cache_time: int = 10800,
+ root_path: str = "",
+ allow_anonymous: bool = True,
+ index_document: Optional[str] = "index.html",
+ fallback_document: Optional[str] = None,
+ ):
+ """
+ Options for static files serving.
+
+ Args:
+ source_folder (str): Path to the source folder containing static files.
+ extensions: The set of files extensions to serve.
+ discovery: Whether to enable file discovery, serving HTML pages for folders.
+ cache_time: Controls the Cache-Control Max-Age in seconds for static files.
+ root_path: Path prefix used for routing requests.
+ For example, if set to "public", files are served at "/public/*".
+ allow_anonymous: Whether to enable anonymous access to static files, true by
+ default.
+ index_document: The name of the index document to display, if present,
+ in folders. Requests for folders that contain a file with matching produce
+ a response with this document.
+ fallback_document: Optional file name, for a document to serve when a
+ response would be otherwise 404 Not Found; e.g. use this to serve SPA that
+ use HTML5 History API for client side routing.
+ """
+ import warnings
+
+ warnings.warn(
+ "The ServeFilesOptions is deprecated and will "
+ "be removed in the version 1.0.0. Update your code to not use this class "
+ "and pass the same arguments to the application.serve_files method. "
+ "For more information see "
+ "https://www.neoteroi.dev/blacksheep/static-files/",
+ DeprecationWarning,
+ )
+
+ if extensions is None:
+ extensions = self.get_default_extensions()
+ self.source_folder = source_folder
+ self.extensions = set(extensions)
+ self.discovery = bool(discovery)
+ self.cache_time = int(cache_time)
+ self.root_path = root_path
+ self.allow_anonymous = allow_anonymous
+ self.index_document = index_document
+ self.fallback_document = fallback_document
+
+ def get_default_extensions(self) -> Set[str]:
+ """Returns a set of extensions that are served by default."""
+ return get_default_extensions()
+
+ def validate(self) -> None:
+ validate_source_path(str(self.source_folder))
+
+
def get_response_for_file(
files_handler: FilesHandler,
request: Request,
@@ -219,7 +293,7 @@ def get_response_for_file(
if request.method == "HEAD":
# NB: responses to HEAD requests don't have a body,
- # and responses with a body in this framework have content-type
+ # and responses with a body in BlackSheep have content-type
# and content-length headers set automatically,
# depending on their content; therefore here it's necessary to set
# content-type and content-length for HEAD
diff --git a/neoteroi/web/server/files/dynamic.py b/blacksheep/server/files/dynamic.py
similarity index 94%
rename from neoteroi/web/server/files/dynamic.py
rename to blacksheep/server/files/dynamic.py
index 7a006e52..4e22114c 100644
--- a/neoteroi/web/server/files/dynamic.py
+++ b/blacksheep/server/files/dynamic.py
@@ -4,14 +4,14 @@
from typing import Awaitable, Callable, Dict, Iterable, Optional, Sequence, Set
from urllib.parse import unquote
-from neoteroi.web import HTMLContent, Request, Response
-from neoteroi.web.common.files.asyncfs import FilesHandler
-from neoteroi.web.common.files.pathsutils import get_file_extension_from_name
-from neoteroi.web.exceptions import NotFound
-from neoteroi.web.server.authorization import allow_anonymous
-from neoteroi.web.server.resources import get_resource_file_content
-from neoteroi.web.server.routing import Route, Router
-from neoteroi.web.utils import join_fragments
+from blacksheep import HTMLContent, Request, Response
+from blacksheep.common.files.asyncfs import FilesHandler
+from blacksheep.common.files.pathsutils import get_file_extension_from_name
+from blacksheep.exceptions import NotFound
+from blacksheep.server.authorization import allow_anonymous
+from blacksheep.server.resources import get_resource_file_content
+from blacksheep.server.routing import Route, Router
+from blacksheep.utils import join_fragments
from . import get_default_extensions, get_response_for_file, validate_source_path
diff --git a/neoteroi/web/server/files/static.py b/blacksheep/server/files/static.py
similarity index 91%
rename from neoteroi/web/server/files/static.py
rename to blacksheep/server/files/static.py
index 1bf9ae9a..27a72c90 100644
--- a/neoteroi/web/server/files/static.py
+++ b/blacksheep/server/files/static.py
@@ -1,7 +1,7 @@
from email.utils import formatdate
-from neoteroi.web.contents import Content
-from neoteroi.web.messages import Request, Response
+from blacksheep.contents import Content
+from blacksheep.messages import Request, Response
def get_response_for_static_content(
diff --git a/neoteroi/web/server/normalization.py b/blacksheep/server/normalization.py
similarity index 98%
rename from neoteroi/web/server/normalization.py
rename to blacksheep/server/normalization.py
index 4954509f..ebe0ad71 100644
--- a/neoteroi/web/server/normalization.py
+++ b/blacksheep/server/normalization.py
@@ -19,12 +19,13 @@
)
from uuid import UUID
-from neoteroi.auth import Identity, User
-from neoteroi.di import ContainerProtocol
-from neoteroi.web import Request, Response
-from neoteroi.web.normalization import copy_special_attributes
-from neoteroi.web.server import responses
-from neoteroi.web.server.routing import Route
+from guardpost import Identity, User
+from rodi import ContainerProtocol
+
+from blacksheep import Request, Response
+from blacksheep.normalization import copy_special_attributes
+from blacksheep.server import responses
+from blacksheep.server.routing import Route
from .bindings import (
Binder,
@@ -115,7 +116,7 @@ def ensure_response(result) -> Response:
"""
When a request handler returns a result that is not an instance of Response,
this method normalizes the output of the method to be either `None`. or an instance
- of `neoteroi.web.messages.Response` class.
+ of `blacksheep.messages.Response` class.
Use this method in custom decorators for request handlers.
"""
diff --git a/neoteroi/web/server/openapi/__init__.py b/blacksheep/server/openapi/__init__.py
similarity index 100%
rename from neoteroi/web/server/openapi/__init__.py
rename to blacksheep/server/openapi/__init__.py
diff --git a/neoteroi/web/server/openapi/common.py b/blacksheep/server/openapi/common.py
similarity index 97%
rename from neoteroi/web/server/openapi/common.py
rename to blacksheep/server/openapi/common.py
index 08fb3fda..3429eb0c 100644
--- a/neoteroi/web/server/openapi/common.py
+++ b/blacksheep/server/openapi/common.py
@@ -28,11 +28,11 @@
from essentials.json import dumps
from openapidocs.common import Format, OpenAPIRoot, Serializer
-from neoteroi.web.messages import Request
-from neoteroi.web.server.application import Application, ApplicationSyncEvent
-from neoteroi.web.server.authorization import allow_anonymous
-from neoteroi.web.server.files.static import get_response_for_static_content
-from neoteroi.web.server.routing import Route, Router
+from blacksheep.messages import Request
+from blacksheep.server.application import Application, ApplicationSyncEvent
+from blacksheep.server.authorization import allow_anonymous
+from blacksheep.server.files.static import get_response_for_static_content
+from blacksheep.server.routing import Route, Router
from .ui import SwaggerUIProvider, UIOptions, UIProvider
diff --git a/neoteroi/web/server/openapi/docstrings.py b/blacksheep/server/openapi/docstrings.py
similarity index 100%
rename from neoteroi/web/server/openapi/docstrings.py
rename to blacksheep/server/openapi/docstrings.py
diff --git a/neoteroi/web/server/openapi/exceptions.py b/blacksheep/server/openapi/exceptions.py
similarity index 100%
rename from neoteroi/web/server/openapi/exceptions.py
rename to blacksheep/server/openapi/exceptions.py
diff --git a/neoteroi/web/server/openapi/ui.py b/blacksheep/server/openapi/ui.py
similarity index 93%
rename from neoteroi/web/server/openapi/ui.py
rename to blacksheep/server/openapi/ui.py
index c2f3a8cf..cea48adc 100644
--- a/neoteroi/web/server/openapi/ui.py
+++ b/blacksheep/server/openapi/ui.py
@@ -3,9 +3,9 @@
from datetime import datetime
from typing import Callable
-from neoteroi.web.messages import Request, Response
-from neoteroi.web.server.files.static import get_response_for_static_content
-from neoteroi.web.server.resources import get_resource_file_content
+from blacksheep.messages import Request, Response
+from blacksheep.server.files.static import get_response_for_static_content
+from blacksheep.server.resources import get_resource_file_content
@dataclass
diff --git a/neoteroi/web/server/openapi/v3.py b/blacksheep/server/openapi/v3.py
similarity index 99%
rename from neoteroi/web/server/openapi/v3.py
rename to blacksheep/server/openapi/v3.py
index 0f4c39a0..6bb134cb 100644
--- a/neoteroi/web/server/openapi/v3.py
+++ b/blacksheep/server/openapi/v3.py
@@ -28,7 +28,7 @@
from openapidocs.v3 import Response as ResponseDoc
from openapidocs.v3 import Schema, Server, ValueFormat, ValueType
-from neoteroi.web.server.bindings import (
+from blacksheep.server.bindings import (
Binder,
BodyBinder,
CookieBinder,
@@ -37,15 +37,15 @@
RouteBinder,
empty,
)
-from neoteroi.web.server.openapi.docstrings import (
+from blacksheep.server.openapi.docstrings import (
DocstringInfo,
get_handler_docstring_info,
)
-from neoteroi.web.server.openapi.exceptions import (
+from blacksheep.server.openapi.exceptions import (
DuplicatedContentTypeDocsException,
UnsupportedUnionTypeException,
)
-from neoteroi.web.server.routing import Router
+from blacksheep.server.routing import Router
from ..application import Application
from .common import (
diff --git a/neoteroi/web/server/remotes/__init__.py b/blacksheep/server/remotes/__init__.py
similarity index 100%
rename from neoteroi/web/server/remotes/__init__.py
rename to blacksheep/server/remotes/__init__.py
diff --git a/neoteroi/web/server/remotes/forwarding.py b/blacksheep/server/remotes/forwarding.py
similarity index 99%
rename from neoteroi/web/server/remotes/forwarding.py
rename to blacksheep/server/remotes/forwarding.py
index 6c35bd13..415191af 100644
--- a/neoteroi/web/server/remotes/forwarding.py
+++ b/blacksheep/server/remotes/forwarding.py
@@ -2,9 +2,9 @@
from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network, ip_address
from typing import AnyStr, Iterable, List, Optional, Sequence, Union
-from neoteroi.web.exceptions import BadRequest
-from neoteroi.web.headers import Headers
-from neoteroi.web.messages import Request
+from blacksheep.exceptions import BadRequest
+from blacksheep.headers import Headers
+from blacksheep.messages import Request
from .hosts import TrustedHostsMiddleware
diff --git a/neoteroi/web/server/remotes/hosts.py b/blacksheep/server/remotes/hosts.py
similarity index 90%
rename from neoteroi/web/server/remotes/hosts.py
rename to blacksheep/server/remotes/hosts.py
index 22968b6b..bc4f7174 100644
--- a/neoteroi/web/server/remotes/hosts.py
+++ b/blacksheep/server/remotes/hosts.py
@@ -1,7 +1,7 @@
from typing import List, Optional, Sequence
-from neoteroi.web.exceptions import BadRequest
-from neoteroi.web.messages import Request
+from blacksheep.exceptions import BadRequest
+from blacksheep.messages import Request
class InvalidHostError(BadRequest):
diff --git a/neoteroi/web/server/rendering/__init__.py b/blacksheep/server/rendering/__init__.py
similarity index 100%
rename from neoteroi/web/server/rendering/__init__.py
rename to blacksheep/server/rendering/__init__.py
diff --git a/neoteroi/web/server/rendering/abc.py b/blacksheep/server/rendering/abc.py
similarity index 100%
rename from neoteroi/web/server/rendering/abc.py
rename to blacksheep/server/rendering/abc.py
diff --git a/neoteroi/web/server/rendering/jinja2.py b/blacksheep/server/rendering/jinja2.py
similarity index 96%
rename from neoteroi/web/server/rendering/jinja2.py
rename to blacksheep/server/rendering/jinja2.py
index 3103e999..91069e1a 100644
--- a/neoteroi/web/server/rendering/jinja2.py
+++ b/blacksheep/server/rendering/jinja2.py
@@ -6,8 +6,8 @@
from jinja2.ext import Extension
from jinja2.utils import pass_context
-from neoteroi.web.messages import Request
-from neoteroi.web.server.csrf import AntiForgeryHandler, MissingRequestContextError
+from blacksheep.messages import Request
+from blacksheep.server.csrf import AntiForgeryHandler, MissingRequestContextError
from .abc import Renderer
diff --git a/neoteroi/web/server/rendering/models.py b/blacksheep/server/rendering/models.py
similarity index 100%
rename from neoteroi/web/server/rendering/models.py
rename to blacksheep/server/rendering/models.py
diff --git a/neoteroi/web/server/res/__init__.py b/blacksheep/server/res/__init__.py
similarity index 100%
rename from neoteroi/web/server/res/__init__.py
rename to blacksheep/server/res/__init__.py
diff --git a/neoteroi/web/server/res/error.css b/blacksheep/server/res/error.css
similarity index 100%
rename from neoteroi/web/server/res/error.css
rename to blacksheep/server/res/error.css
diff --git a/neoteroi/web/server/res/error.html b/blacksheep/server/res/error.html
similarity index 100%
rename from neoteroi/web/server/res/error.html
rename to blacksheep/server/res/error.html
diff --git a/neoteroi/web/server/res/fileslist.html b/blacksheep/server/res/fileslist.html
similarity index 100%
rename from neoteroi/web/server/res/fileslist.html
rename to blacksheep/server/res/fileslist.html
diff --git a/neoteroi/web/server/res/redoc-ui.html b/blacksheep/server/res/redoc-ui.html
similarity index 100%
rename from neoteroi/web/server/res/redoc-ui.html
rename to blacksheep/server/res/redoc-ui.html
diff --git a/neoteroi/web/server/res/swagger-ui.html b/blacksheep/server/res/swagger-ui.html
similarity index 100%
rename from neoteroi/web/server/res/swagger-ui.html
rename to blacksheep/server/res/swagger-ui.html
diff --git a/neoteroi/web/server/resources.py b/blacksheep/server/resources.py
similarity index 100%
rename from neoteroi/web/server/resources.py
rename to blacksheep/server/resources.py
diff --git a/neoteroi/web/server/responses.py b/blacksheep/server/responses.py
similarity index 95%
rename from neoteroi/web/server/responses.py
rename to blacksheep/server/responses.py
index 5a45798b..637917a4 100644
--- a/neoteroi/web/server/responses.py
+++ b/blacksheep/server/responses.py
@@ -4,10 +4,10 @@
from io import BytesIO
from typing import Any, AnyStr, AsyncIterable, Callable, Optional, Union
-from neoteroi.web import Content, JSONContent, Response, StreamedContent, TextContent
-from neoteroi.web.common.files.asyncfs import FilesHandler
-from neoteroi.web.settings.html import html_settings
-from neoteroi.web.settings.json import json_settings
+from blacksheep import Content, JSONContent, Response, StreamedContent, TextContent
+from blacksheep.common.files.asyncfs import FilesHandler
+from blacksheep.settings.html import html_settings
+from blacksheep.settings.json import json_settings
MessageType = Any
@@ -332,8 +332,8 @@ def view(name: str, model: Any = None, **kwargs) -> Response:
Returns a Response object with HTML obtained using synchronous rendering.
This method relies on the engine configured for rendering (defaults to Jinja2):
- see `neoteroi.web.settings.html.html_settings.renderer`
- and `neoteroi.web.server.rendering.abc.Renderer`.
+ see `blacksheep.settings.html.html_settings.renderer`
+ and `blacksheep.server.rendering.abc.Renderer`.
"""
renderer = html_settings.renderer
if model:
@@ -348,8 +348,8 @@ async def view_async(name: str, model: Any = None, **kwargs) -> Response:
Returns a Response object with HTML obtained using asynchronous rendering.
This method relies on the engine configured for rendering (defaults to Jinja2):
- see `neoteroi.web.settings.html.html_settings.renderer`
- and `neoteroi.web.server.rendering.abc.Renderer`.
+ see `blacksheep.settings.html.html_settings.renderer`
+ and `blacksheep.server.rendering.abc.Renderer`.
"""
renderer = html_settings.renderer
if model:
diff --git a/neoteroi/web/server/routing.py b/blacksheep/server/routing.py
similarity index 99%
rename from neoteroi/web/server/routing.py
rename to blacksheep/server/routing.py
index 16681a61..49060167 100644
--- a/neoteroi/web/server/routing.py
+++ b/blacksheep/server/routing.py
@@ -6,7 +6,7 @@
from typing import Any, AnyStr, Callable, Dict, List, Optional, Set, Union
from urllib.parse import unquote
-from neoteroi.web.utils import ensure_bytes, ensure_str
+from blacksheep.utils import ensure_bytes, ensure_str
__all__ = [
"HTTPMethod",
@@ -139,6 +139,7 @@ def _get_regex_for_pattern(self, pattern: bytes):
Converts a raw pattern into a compiled regular expression that can be used
to match bytes URL paths, extracting route parameters.
"""
+ # TODO: should blacksheep support ":" in routes (using escape chars)?
for c in _escaped_chars:
if c in pattern:
pattern = pattern.replace(c, b"\\" + c)
diff --git a/neoteroi/web/server/security/__init__.py b/blacksheep/server/security/__init__.py
similarity index 89%
rename from neoteroi/web/server/security/__init__.py
rename to blacksheep/server/security/__init__.py
index 1617dee1..70835306 100644
--- a/neoteroi/web/server/security/__init__.py
+++ b/blacksheep/server/security/__init__.py
@@ -1,6 +1,6 @@
from abc import ABC, abstractmethod
-from neoteroi.web.messages import Response
+from blacksheep.messages import Response
class SecurityPolicyHandler(ABC):
diff --git a/neoteroi/web/server/security/hsts.py b/blacksheep/server/security/hsts.py
similarity index 93%
rename from neoteroi/web/server/security/hsts.py
rename to blacksheep/server/security/hsts.py
index 46eb4859..46245a05 100644
--- a/neoteroi/web/server/security/hsts.py
+++ b/blacksheep/server/security/hsts.py
@@ -1,4 +1,4 @@
-from neoteroi.web.messages import Request, Response
+from blacksheep.messages import Request, Response
def _get_hsts_value(max_age: int, include_subdomains: bool) -> bytes:
diff --git a/neoteroi/web/server/websocket.py b/blacksheep/server/websocket.py
similarity index 97%
rename from neoteroi/web/server/websocket.py
rename to blacksheep/server/websocket.py
index 0cfbcec9..50590076 100644
--- a/neoteroi/web/server/websocket.py
+++ b/blacksheep/server/websocket.py
@@ -2,9 +2,9 @@
from functools import wraps
from typing import Any, AnyStr, Callable, List, MutableMapping, Optional
-from neoteroi.web.messages import Request
-from neoteroi.web.server.asgi import get_full_path
-from neoteroi.web.settings.json import json_settings
+from blacksheep.messages import Request
+from blacksheep.server.asgi import get_full_path
+from blacksheep.settings.json import json_settings
class WebSocketState(Enum):
diff --git a/neoteroi/web/sessions/__init__.py b/blacksheep/sessions/__init__.py
similarity index 95%
rename from neoteroi/web/sessions/__init__.py
rename to blacksheep/sessions/__init__.py
index 327a3b38..52eacdba 100644
--- a/neoteroi/web/sessions/__init__.py
+++ b/blacksheep/sessions/__init__.py
@@ -6,14 +6,14 @@
from itsdangerous import Serializer, URLSafeTimedSerializer # noqa
from itsdangerous.exc import BadSignature, SignatureExpired
-from neoteroi.web.cookies import Cookie
-from neoteroi.web.messages import Request, Response
-from neoteroi.web.settings.json import json_settings
-from neoteroi.web.utils import ensure_str
+from blacksheep.cookies import Cookie
+from blacksheep.messages import Request, Response
+from blacksheep.settings.json import json_settings
+from blacksheep.utils import ensure_str
def get_logger():
- logger = logging.getLogger("neoteroi.web.sessions")
+ logger = logging.getLogger("blacksheep.sessions")
logger.setLevel(logging.INFO)
return logger
diff --git a/blacksheep/settings/__init__.py b/blacksheep/settings/__init__.py
new file mode 100644
index 00000000..6b0004a7
--- /dev/null
+++ b/blacksheep/settings/__init__.py
@@ -0,0 +1,3 @@
+"""
+This package contains global settings for a BlackSheep application.
+"""
diff --git a/neoteroi/web/settings/di.py b/blacksheep/settings/di.py
similarity index 94%
rename from neoteroi/web/settings/di.py
rename to blacksheep/settings/di.py
index ed229167..76c7f7e9 100644
--- a/neoteroi/web/settings/di.py
+++ b/blacksheep/settings/di.py
@@ -1,6 +1,6 @@
from typing import Callable, Optional, Type, TypeVar, Union
-from neoteroi.di import Container, ContainerProtocol, Services
+from rodi import Container, ContainerProtocol, Services
T = TypeVar("T")
diff --git a/neoteroi/web/settings/html.py b/blacksheep/settings/html.py
similarity index 81%
rename from neoteroi/web/settings/html.py
rename to blacksheep/settings/html.py
index d583b589..5ec90ee3 100644
--- a/neoteroi/web/settings/html.py
+++ b/blacksheep/settings/html.py
@@ -1,11 +1,11 @@
from typing import Any, List
-from neoteroi.web.server.rendering.abc import ModelHandler, Renderer
-from neoteroi.web.server.rendering.models import DefaultModelHandler
+from blacksheep.server.rendering.abc import ModelHandler, Renderer
+from blacksheep.server.rendering.models import DefaultModelHandler
def default_renderer() -> Renderer:
- from neoteroi.web.server.rendering.jinja2 import JinjaRenderer
+ from blacksheep.server.rendering.jinja2 import JinjaRenderer
return JinjaRenderer()
diff --git a/neoteroi/web/settings/json.py b/blacksheep/settings/json.py
similarity index 100%
rename from neoteroi/web/settings/json.py
rename to blacksheep/settings/json.py
diff --git a/blacksheep/testing/__init__.py b/blacksheep/testing/__init__.py
new file mode 100644
index 00000000..f3896da3
--- /dev/null
+++ b/blacksheep/testing/__init__.py
@@ -0,0 +1,14 @@
+from blacksheep.contents import FormContent, JSONContent, TextContent
+from blacksheep.testing.client import TestClient
+from blacksheep.testing.messages import MockReceive, MockSend
+from blacksheep.testing.simulator import AbstractTestSimulator
+
+__all__ = [
+ "TestClient",
+ "AbstractTestSimulator",
+ "JSONContent",
+ "TextContent",
+ "FormContent",
+ "MockReceive",
+ "MockSend",
+]
diff --git a/neoteroi/web/testing/client.py b/blacksheep/testing/client.py
similarity index 94%
rename from neoteroi/web/testing/client.py
rename to blacksheep/testing/client.py
index 4ecbf45f..3bfa95c3 100644
--- a/neoteroi/web/testing/client.py
+++ b/blacksheep/testing/client.py
@@ -1,9 +1,9 @@
from typing import Optional
-from neoteroi.web.contents import Content
-from neoteroi.web.server.application import Application
-from neoteroi.web.server.responses import Response
-from neoteroi.web.testing.simulator import AbstractTestSimulator, TestSimulator
+from blacksheep.contents import Content
+from blacksheep.server.application import Application
+from blacksheep.server.responses import Response
+from blacksheep.testing.simulator import AbstractTestSimulator, TestSimulator
from .helpers import CookiesType, HeadersType, QueryType
diff --git a/neoteroi/web/testing/helpers.py b/blacksheep/testing/helpers.py
similarity index 100%
rename from neoteroi/web/testing/helpers.py
rename to blacksheep/testing/helpers.py
diff --git a/neoteroi/web/testing/messages.py b/blacksheep/testing/messages.py
similarity index 100%
rename from neoteroi/web/testing/messages.py
rename to blacksheep/testing/messages.py
diff --git a/neoteroi/web/testing/simulator.py b/blacksheep/testing/simulator.py
similarity index 87%
rename from neoteroi/web/testing/simulator.py
rename to blacksheep/testing/simulator.py
index cdadef32..32506197 100644
--- a/neoteroi/web/testing/simulator.py
+++ b/blacksheep/testing/simulator.py
@@ -1,11 +1,11 @@
import abc
from typing import Dict, Optional
-from neoteroi.web.contents import Content
-from neoteroi.web.messages import Request
-from neoteroi.web.server.application import Application
-from neoteroi.web.server.responses import Response
-from neoteroi.web.testing.helpers import get_example_scope
+from blacksheep.contents import Content
+from blacksheep.messages import Request
+from blacksheep.server.application import Application
+from blacksheep.server.responses import Response
+from blacksheep.testing.helpers import get_example_scope
from .helpers import CookiesType, HeadersType, QueryType
@@ -93,4 +93,4 @@ async def send_request(
def _is_started_app(self):
assert (
self.app.started
- ), "The web application is not started, use Application.start method"
+ ), "The BlackSheep application is not started, use Application.start method"
diff --git a/neoteroi/web/url.pxd b/blacksheep/url.pxd
similarity index 100%
rename from neoteroi/web/url.pxd
rename to blacksheep/url.pxd
diff --git a/neoteroi/web/url.pyi b/blacksheep/url.pyi
similarity index 100%
rename from neoteroi/web/url.pyi
rename to blacksheep/url.pyi
diff --git a/neoteroi/web/url.pyx b/blacksheep/url.pyx
similarity index 100%
rename from neoteroi/web/url.pyx
rename to blacksheep/url.pyx
diff --git a/neoteroi/web/utils/__init__.py b/blacksheep/utils/__init__.py
similarity index 100%
rename from neoteroi/web/utils/__init__.py
rename to blacksheep/utils/__init__.py
diff --git a/neoteroi/web/utils/aio.py b/blacksheep/utils/aio.py
similarity index 100%
rename from neoteroi/web/utils/aio.py
rename to blacksheep/utils/aio.py
diff --git a/itests/app_1.py b/itests/app_1.py
index 030a606e..7fe41b57 100644
--- a/itests/app_1.py
+++ b/itests/app_1.py
@@ -5,8 +5,7 @@
import uvicorn
-from itests.utils import CrashTest, ensure_folder
-from neoteroi.web import (
+from blacksheep import (
Application,
Content,
ContentDispositionType,
@@ -18,6 +17,7 @@
json,
text,
)
+from itests.utils import CrashTest, ensure_folder
app = Application(show_error_details=True)
diff --git a/itests/app_2.py b/itests/app_2.py
index f5c322a5..430f1c01 100644
--- a/itests/app_2.py
+++ b/itests/app_2.py
@@ -9,20 +9,19 @@
import uvicorn
from dateutil.parser import parse as dateutil_parse
+from guardpost import AuthorizationContext, Identity
+from guardpost.common import AuthenticatedRequirement
from openapidocs.v3 import Discriminator, Info, MediaType, Operation
from openapidocs.v3 import Response as ResponseDoc
from openapidocs.v3 import Schema
from pydantic import BaseModel
-from itests.utils import CrashTest
-from neoteroi.auth import AuthorizationContext, Identity
-from neoteroi.auth.common import AuthenticatedRequirement
-from neoteroi.web import Response, TextContent, WebSocket
-from neoteroi.web.exceptions import BadRequest
-from neoteroi.web.server import Application
-from neoteroi.web.server.authentication import AuthenticationHandler
-from neoteroi.web.server.authorization import Policy, Requirement, auth
-from neoteroi.web.server.bindings import (
+from blacksheep import Response, TextContent, WebSocket
+from blacksheep.exceptions import BadRequest
+from blacksheep.server import Application
+from blacksheep.server.authentication import AuthenticationHandler
+from blacksheep.server.authorization import Policy, Requirement, auth
+from blacksheep.server.bindings import (
FromCookie,
FromForm,
FromHeader,
@@ -30,8 +29,8 @@
FromQuery,
FromServices,
)
-from neoteroi.web.server.controllers import APIController
-from neoteroi.web.server.openapi.common import (
+from blacksheep.server.controllers import APIController
+from blacksheep.server.openapi.common import (
ContentInfo,
EndpointDocs,
HeaderInfo,
@@ -41,10 +40,11 @@
ResponseExample,
ResponseInfo,
)
-from neoteroi.web.server.openapi.ui import ReDocUIProvider
-from neoteroi.web.server.openapi.v3 import OpenAPIHandler
-from neoteroi.web.server.responses import text
-from neoteroi.web.server.routing import RoutesRegistry
+from blacksheep.server.openapi.ui import ReDocUIProvider
+from blacksheep.server.openapi.v3 import OpenAPIHandler
+from blacksheep.server.responses import text
+from blacksheep.server.routing import RoutesRegistry
+from itests.utils import CrashTest
app_2 = Application()
diff --git a/itests/app_3.py b/itests/app_3.py
index 08bb374e..7c232180 100644
--- a/itests/app_3.py
+++ b/itests/app_3.py
@@ -1,7 +1,7 @@
import uvicorn
-from neoteroi.web.server import Application
-from neoteroi.web.server.responses import json
+from blacksheep.server import Application
+from blacksheep.server.responses import json
application = Application(show_error_details=True)
app_3 = Application(show_error_details=True)
diff --git a/itests/app_4.py b/itests/app_4.py
index 259279c5..cb47c319 100644
--- a/itests/app_4.py
+++ b/itests/app_4.py
@@ -6,12 +6,12 @@
import uvicorn
-from neoteroi.web import JSONContent, Response
-from neoteroi.web.server import Application
-from neoteroi.web.server.bindings import FromJSON
-from neoteroi.web.server.responses import json
-from neoteroi.web.server.websocket import WebSocket
-from neoteroi.web.settings.json import default_json_dumps, json_settings
+from blacksheep import JSONContent, Response
+from blacksheep.server import Application
+from blacksheep.server.bindings import FromJSON
+from blacksheep.server.responses import json
+from blacksheep.server.websocket import WebSocket
+from blacksheep.settings.json import default_json_dumps, json_settings
SINGLE_PID = None
diff --git a/itests/client_fixtures.py b/itests/client_fixtures.py
index 54105039..7394f70f 100644
--- a/itests/client_fixtures.py
+++ b/itests/client_fixtures.py
@@ -6,9 +6,9 @@
import pytest
+from blacksheep.client import ClientSession
+from blacksheep.client.pool import ClientConnectionPools
from itests.utils import get_sleep_time
-from neoteroi.web.client import ClientSession
-from neoteroi.web.client.pool import ClientConnectionPools
from .flask_app import app
diff --git a/itests/test_auth_oidc.py b/itests/test_auth_oidc.py
index b4a3c982..0abbf86a 100644
--- a/itests/test_auth_oidc.py
+++ b/itests/test_auth_oidc.py
@@ -7,16 +7,16 @@
from urllib.parse import parse_qs, urlencode
import pytest
-
-from neoteroi.auth import Identity, Policy
-from neoteroi.auth.common import AuthenticatedRequirement
-from neoteroi.web.cookies import parse_cookie
-from neoteroi.web.exceptions import BadRequest, Unauthorized
-from neoteroi.web.messages import Request, Response
-from neoteroi.web.server.application import Application
-from neoteroi.web.server.asgi import incoming_request
-from neoteroi.web.server.authentication.cookie import CookieAuthentication
-from neoteroi.web.server.authentication.oidc import (
+from guardpost import Identity, Policy
+from guardpost.common import AuthenticatedRequirement
+
+from blacksheep.cookies import parse_cookie
+from blacksheep.exceptions import BadRequest, Unauthorized
+from blacksheep.messages import Request, Response
+from blacksheep.server.application import Application
+from blacksheep.server.asgi import incoming_request
+from blacksheep.server.authentication.cookie import CookieAuthentication
+from blacksheep.server.authentication.oidc import (
CookiesTokensStore,
MissingClientSecretSettingError,
OpenIDConfiguration,
@@ -30,10 +30,10 @@
TokenResponse,
use_openid_connect,
)
-from neoteroi.web.testing.helpers import get_example_scope
-from neoteroi.web.testing.messages import MockReceive, MockSend
-from neoteroi.web.url import URL
-from neoteroi.web.utils.aio import FailedRequestError
+from blacksheep.testing.helpers import get_example_scope
+from blacksheep.testing.messages import MockReceive, MockSend
+from blacksheep.url import URL
+from blacksheep.utils.aio import FailedRequestError
from tests.test_auth import get_access_token
from tests.test_auth_cookie import get_auth_cookie
from tests.utils.application import FakeApplication
diff --git a/itests/test_client.py b/itests/test_client.py
index 5d441659..82380138 100644
--- a/itests/test_client.py
+++ b/itests/test_client.py
@@ -4,7 +4,7 @@
import pytest
-from neoteroi.web import FormContent, FormPart, JSONContent, MultiPartFormData, Response
+from blacksheep import FormContent, FormPart, JSONContent, MultiPartFormData, Response
from .client_fixtures import * # NoQA
from .client_fixtures import get_static_path
diff --git a/itests/test_utils_aio.py b/itests/test_utils_aio.py
index b54c30ec..09b96c6f 100644
--- a/itests/test_utils_aio.py
+++ b/itests/test_utils_aio.py
@@ -2,7 +2,7 @@
import pytest
-from neoteroi.web.utils.aio import (
+from blacksheep.utils.aio import (
FailedRequestError,
HTTPHandler,
_try_parse_content_as_json,
diff --git a/neoteroi/__init__.pyx b/neoteroi/__init__.pyx
deleted file mode 100644
index ac0fab18..00000000
--- a/neoteroi/__init__.pyx
+++ /dev/null
@@ -1 +0,0 @@
-# This file is necessary to make Cython work with a namespace package.
diff --git a/neoteroi/web/__init__.py b/neoteroi/web/__init__.py
deleted file mode 100644
index 7d0a3501..00000000
--- a/neoteroi/web/__init__.py
+++ /dev/null
@@ -1,80 +0,0 @@
-"""
-Root module of the framework. This module re-exports the most commonly
-used types to reduce the verbosity of the imports statements.
-"""
-__author__ = "Roberto Prevato "
-
-from neoteroi.web.contents import Content as Content
-from neoteroi.web.contents import FormContent as FormContent
-from neoteroi.web.contents import FormPart as FormPart
-from neoteroi.web.contents import HTMLContent as HTMLContent
-from neoteroi.web.contents import HtmlContent as HtmlContent
-from neoteroi.web.contents import JSONContent as JSONContent
-from neoteroi.web.contents import MultiPartFormData as MultiPartFormData
-from neoteroi.web.contents import StreamedContent as StreamedContent
-from neoteroi.web.contents import TextContent as TextContent
-from neoteroi.web.contents import parse_www_form as parse_www_form
-from neoteroi.web.cookies import Cookie as Cookie
-from neoteroi.web.cookies import CookieSameSiteMode as CookieSameSiteMode
-from neoteroi.web.cookies import (
- datetime_from_cookie_format as datetime_from_cookie_format,
-)
-from neoteroi.web.cookies import datetime_to_cookie_format as datetime_to_cookie_format
-from neoteroi.web.cookies import parse_cookie as parse_cookie
-from neoteroi.web.exceptions import HTTPException as HTTPException
-from neoteroi.web.headers import Header as Header
-from neoteroi.web.headers import Headers as Headers
-from neoteroi.web.messages import Message as Message
-from neoteroi.web.messages import Request as Request
-from neoteroi.web.messages import Response as Response
-from neoteroi.web.server.application import Application as Application
-from neoteroi.web.server.authorization import allow_anonymous as allow_anonymous
-from neoteroi.web.server.authorization import auth as auth
-from neoteroi.web.server.bindings import ClientInfo as ClientInfo
-from neoteroi.web.server.bindings import FromBytes as FromBytes
-from neoteroi.web.server.bindings import FromCookie as FromCookie
-from neoteroi.web.server.bindings import FromFiles as FromFiles
-from neoteroi.web.server.bindings import FromForm as FromForm
-from neoteroi.web.server.bindings import FromHeader as FromHeader
-from neoteroi.web.server.bindings import FromJSON as FromJSON
-from neoteroi.web.server.bindings import FromQuery as FromQuery
-from neoteroi.web.server.bindings import FromRoute as FromRoute
-from neoteroi.web.server.bindings import FromServices as FromServices
-from neoteroi.web.server.bindings import FromText as FromText
-from neoteroi.web.server.bindings import ServerInfo as ServerInfo
-from neoteroi.web.server.responses import (
- ContentDispositionType as ContentDispositionType,
-)
-from neoteroi.web.server.responses import FileInput as FileInput
-from neoteroi.web.server.responses import accepted as accepted
-from neoteroi.web.server.responses import bad_request as bad_request
-from neoteroi.web.server.responses import created as created
-from neoteroi.web.server.responses import file as file
-from neoteroi.web.server.responses import forbidden as forbidden
-from neoteroi.web.server.responses import html as html
-from neoteroi.web.server.responses import json as json
-from neoteroi.web.server.responses import moved_permanently as moved_permanently
-from neoteroi.web.server.responses import no_content as no_content
-from neoteroi.web.server.responses import not_found as not_found
-from neoteroi.web.server.responses import not_modified as not_modified
-from neoteroi.web.server.responses import ok as ok
-from neoteroi.web.server.responses import permanent_redirect as permanent_redirect
-from neoteroi.web.server.responses import pretty_json as pretty_json
-from neoteroi.web.server.responses import redirect as redirect
-from neoteroi.web.server.responses import see_other as see_other
-from neoteroi.web.server.responses import status_code as status_code
-from neoteroi.web.server.responses import temporary_redirect as temporary_redirect
-from neoteroi.web.server.responses import text as text
-from neoteroi.web.server.responses import unauthorized as unauthorized
-from neoteroi.web.server.routing import Route as Route
-from neoteroi.web.server.routing import RouteException as RouteException
-from neoteroi.web.server.routing import Router as Router
-from neoteroi.web.server.routing import RoutesRegistry as RoutesRegistry
-from neoteroi.web.server.websocket import WebSocket as WebSocket
-from neoteroi.web.server.websocket import (
- WebSocketDisconnectError as WebSocketDisconnectError,
-)
-from neoteroi.web.server.websocket import WebSocketError as WebSocketError
-from neoteroi.web.server.websocket import WebSocketState as WebSocketState
-from neoteroi.web.url import URL as URL
-from neoteroi.web.url import InvalidURL as InvalidURL
diff --git a/neoteroi/web/includes/consts.pxi b/neoteroi/web/includes/consts.pxi
deleted file mode 100644
index a8c15530..00000000
--- a/neoteroi/web/includes/consts.pxi
+++ /dev/null
@@ -1,4 +0,0 @@
-DEF MAX_RESPONSE_CHUNK_SIZE = 61440 # 64kb
-
-# 61440 # 64kb
-# 16384
diff --git a/neoteroi/web/settings/__init__.py b/neoteroi/web/settings/__init__.py
deleted file mode 100644
index e7abee73..00000000
--- a/neoteroi/web/settings/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-"""
-This package contains global settings for the web application.
-"""
diff --git a/neoteroi/web/testing/__init__.py b/neoteroi/web/testing/__init__.py
deleted file mode 100644
index f0b332bc..00000000
--- a/neoteroi/web/testing/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from neoteroi.web.contents import FormContent, JSONContent, TextContent
-from neoteroi.web.testing.client import TestClient
-from neoteroi.web.testing.messages import MockReceive, MockSend
-from neoteroi.web.testing.simulator import AbstractTestSimulator
-
-__all__ = [
- "TestClient",
- "AbstractTestSimulator",
- "JSONContent",
- "TextContent",
- "FormContent",
- "MockReceive",
- "MockSend",
-]
diff --git a/requirements.txt b/requirements.txt
index 81d8aa5e..5860a753 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -13,7 +13,7 @@ essentials-openapi==1.0.3
Flask==2.2.2
gevent==22.10.1
greenlet==1.1.3.post0
-neoteroi-auth==0.0.3
+guardpost~=1.0.0
h11==0.11.0
h2==4.1.0
hpack==4.0.0
@@ -41,7 +41,7 @@ python-dateutil==2.8.2
PyYAML==6.0
regex==2020.4.4
requests==2.28.1
-neoteroi-di==0.0.4
+rodi~=2.0.0
six==1.16.0
toml==0.10.1
tomli==2.0.1
diff --git a/setup.py b/setup.py
index 2eb4294f..0fed4d41 100644
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@ def readme():
setup(
- name="neoteroi-web",
+ name="blacksheep",
version="2.0.0",
description="Fast web framework for Python asyncio",
long_description=readme(),
@@ -30,66 +30,66 @@ def readme():
url="https://github.com/Neoteroi/BlackSheep",
author="Roberto Prevato",
author_email="roberto.prevato@gmail.com",
- keywords="Neoteroi web framework",
+ keywords="BlackSheep web framework",
platforms=["*nix"],
license="MIT",
packages=[
- "neoteroi.web",
- "neoteroi.web.server",
- "neoteroi.web.server.authentication",
- "neoteroi.web.server.authorization",
- "neoteroi.web.server.files",
- "neoteroi.web.server.remotes",
- "neoteroi.web.server.res",
- "neoteroi.web.server.openapi",
- "neoteroi.web.server.security",
- "neoteroi.web.settings",
- "neoteroi.web.client",
- "neoteroi.web.common",
- "neoteroi.web.common.files",
- "neoteroi.web.sessions",
- "neoteroi.web.testing",
- "neoteroi.web.utils",
+ "blacksheep",
+ "blacksheep.server",
+ "blacksheep.server.authentication",
+ "blacksheep.server.authorization",
+ "blacksheep.server.files",
+ "blacksheep.server.remotes",
+ "blacksheep.server.res",
+ "blacksheep.server.openapi",
+ "blacksheep.server.security",
+ "blacksheep.settings",
+ "blacksheep.client",
+ "blacksheep.common",
+ "blacksheep.common.files",
+ "blacksheep.sessions",
+ "blacksheep.testing",
+ "blacksheep.utils",
],
ext_modules=[
Extension(
- "neoteroi.web.url",
- ["neoteroi/web/url.c"],
+ "blacksheep.url",
+ ["blacksheep/url.c"],
extra_compile_args=COMPILE_ARGS,
),
Extension(
- "neoteroi.web.exceptions",
- ["neoteroi/web/exceptions.c"],
+ "blacksheep.exceptions",
+ ["blacksheep/exceptions.c"],
extra_compile_args=COMPILE_ARGS,
),
Extension(
- "neoteroi.web.headers",
- ["neoteroi/web/headers.c"],
+ "blacksheep.headers",
+ ["blacksheep/headers.c"],
extra_compile_args=COMPILE_ARGS,
),
Extension(
- "neoteroi.web.cookies",
- ["neoteroi/web/cookies.c"],
+ "blacksheep.cookies",
+ ["blacksheep/cookies.c"],
extra_compile_args=COMPILE_ARGS,
),
Extension(
- "neoteroi.web.contents",
- ["neoteroi/web/contents.c"],
+ "blacksheep.contents",
+ ["blacksheep/contents.c"],
extra_compile_args=COMPILE_ARGS,
),
Extension(
- "neoteroi.web.messages",
- ["neoteroi/web/messages.c"],
+ "blacksheep.messages",
+ ["blacksheep/messages.c"],
extra_compile_args=COMPILE_ARGS,
),
Extension(
- "neoteroi.web.scribe",
- ["neoteroi/web/scribe.c"],
+ "blacksheep.scribe",
+ ["blacksheep/scribe.c"],
extra_compile_args=COMPILE_ARGS,
),
Extension(
- "neoteroi.web.baseapp",
- ["neoteroi/web/baseapp.c"],
+ "blacksheep.baseapp",
+ ["blacksheep/baseapp.c"],
extra_compile_args=COMPILE_ARGS,
),
],
@@ -98,8 +98,8 @@ def readme():
"certifi>=2022.9.24",
"cchardet~=2.1.7; python_version < '3.11'",
"chardet==5.0.0; python_version > '3.10'",
- "neoteroi-auth==0.0.3", # ~=1.0.0
- "neoteroi-di==0.0.4", # ~=2.0.0
+ "guardpost~=1.0.0",
+ "rodi~=2.0.0",
"essentials>=1.1.4,<2.0",
"essentials-openapi>=0.1.4,<1.0",
"typing_extensions; python_version < '3.8'",
diff --git a/tests/client/__init__.py b/tests/client/__init__.py
index d1605b8b..a2f6fc52 100644
--- a/tests/client/__init__.py
+++ b/tests/client/__init__.py
@@ -1,8 +1,5 @@
-"""
-These classes implement the interface used by the HTTP client implementation, to
-simplify testing on the ClientSession object; including handling of connections and
-requests timeouts; redirects, etc.
-"""
+"""These classes implement the interface used by BlackSheep HTTP client implementation, to simplify testing on the
+ClientSession object; including handling of connections and requests timeouts; redirects, etc."""
import asyncio
diff --git a/tests/client/test_client.py b/tests/client/test_client.py
index 76288141..de1baec8 100644
--- a/tests/client/test_client.py
+++ b/tests/client/test_client.py
@@ -1,9 +1,9 @@
import pytest
-from neoteroi.web import URL, Request, Response
-from neoteroi.web.client import ClientSession
-from neoteroi.web.client.connection import ClientConnection, ConnectionClosedError
-from neoteroi.web.client.exceptions import UnsupportedRedirect
+from blacksheep import URL, Request, Response
+from blacksheep.client import ClientSession
+from blacksheep.client.connection import ClientConnection, ConnectionClosedError
+from blacksheep.client.exceptions import UnsupportedRedirect
@pytest.mark.parametrize(
diff --git a/tests/client/test_connection.py b/tests/client/test_connection.py
index d6c2bef4..60cba900 100644
--- a/tests/client/test_connection.py
+++ b/tests/client/test_connection.py
@@ -5,15 +5,15 @@
import pytest
from httptools.parser.errors import HttpParserCallbackError, HttpParserError
-from neoteroi.web import JSONContent, Request, StreamedContent
-from neoteroi.web.client.connection import (
+from blacksheep import JSONContent, Request, StreamedContent
+from blacksheep.client.connection import (
ClientConnection,
ConnectionClosedError,
IncomingContent,
InvalidResponseFromServer,
UpgradeResponse,
)
-from neoteroi.web.client.pool import ClientConnectionPool
+from blacksheep.client.pool import ClientConnectionPool
def get_example_headers():
diff --git a/tests/client/test_cookiejar.py b/tests/client/test_cookiejar.py
index 88d9b701..99d9bfaa 100644
--- a/tests/client/test_cookiejar.py
+++ b/tests/client/test_cookiejar.py
@@ -2,16 +2,16 @@
import pytest
-from neoteroi.web import URL, Cookie, Response, TextContent
-from neoteroi.web.client import ClientSession
-from neoteroi.web.client.cookies import (
+from blacksheep import URL, Cookie, Response, TextContent
+from blacksheep.client import ClientSession
+from blacksheep.client.cookies import (
CookieJar,
InvalidCookieDomain,
MissingSchemeInURL,
StoredCookie,
)
-from neoteroi.web.cookies import datetime_from_cookie_format
-from neoteroi.web.scribe import write_response_cookie
+from blacksheep.cookies import datetime_from_cookie_format
+from blacksheep.scribe import write_response_cookie
from . import FakePools
diff --git a/tests/client/test_headers.py b/tests/client/test_headers.py
index 8bc372b3..16b82d9f 100644
--- a/tests/client/test_headers.py
+++ b/tests/client/test_headers.py
@@ -1,7 +1,7 @@
import pytest
-from neoteroi.web import Response, TextContent
-from neoteroi.web.client import ClientSession
+from blacksheep import Response, TextContent
+from blacksheep.client import ClientSession
from . import FakePools
diff --git a/tests/client/test_middlewares.py b/tests/client/test_middlewares.py
index eb55aca9..8eb7c475 100644
--- a/tests/client/test_middlewares.py
+++ b/tests/client/test_middlewares.py
@@ -1,7 +1,7 @@
import pytest
-from neoteroi.web import Response, TextContent
-from neoteroi.web.client import ClientSession
+from blacksheep import Response, TextContent
+from blacksheep.client import ClientSession
from . import FakePools
diff --git a/tests/client/test_pool.py b/tests/client/test_pool.py
index ec19a246..8d6adaa3 100644
--- a/tests/client/test_pool.py
+++ b/tests/client/test_pool.py
@@ -2,14 +2,14 @@
import pytest
-from neoteroi.web.client.connection import (
+from blacksheep.client.connection import (
INSECURE_SSLCONTEXT,
SECURE_SSLCONTEXT,
ClientConnection,
)
-from neoteroi.web.client.pool import ClientConnectionPool, get_ssl_context
-from neoteroi.web.exceptions import InvalidArgument
-from neoteroi.web.utils.aio import get_running_loop
+from blacksheep.client.pool import ClientConnectionPool, get_ssl_context
+from blacksheep.exceptions import InvalidArgument
+from blacksheep.utils.aio import get_running_loop
example_context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS_CLIENT)
example_context.check_hostname = False
diff --git a/tests/client/test_query.py b/tests/client/test_query.py
index 5984aad5..0fb481e6 100644
--- a/tests/client/test_query.py
+++ b/tests/client/test_query.py
@@ -1,7 +1,7 @@
import pytest
-from neoteroi.web import Response, TextContent
-from neoteroi.web.client import ClientSession
+from blacksheep import Response, TextContent
+from blacksheep.client import ClientSession
from . import FakePools
diff --git a/tests/client/test_redirects.py b/tests/client/test_redirects.py
index a732d92c..6fe16e67 100644
--- a/tests/client/test_redirects.py
+++ b/tests/client/test_redirects.py
@@ -2,14 +2,14 @@
import pytest
-from neoteroi.web import URL, HTMLContent, Response, TextContent
-from neoteroi.web.client import (
+from blacksheep import URL, HTMLContent, Response, TextContent
+from blacksheep.client import (
CircularRedirectError,
ClientSession,
MaximumRedirectsExceededError,
)
-from neoteroi.web.client.exceptions import MissingLocationForRedirect
-from neoteroi.web.client.session import RedirectsCache
+from blacksheep.client.exceptions import MissingLocationForRedirect
+from blacksheep.client.session import RedirectsCache
from . import FakePools
diff --git a/tests/client/test_timeouts.py b/tests/client/test_timeouts.py
index 2e960289..2d32f468 100644
--- a/tests/client/test_timeouts.py
+++ b/tests/client/test_timeouts.py
@@ -1,6 +1,6 @@
import pytest
-from neoteroi.web.client import ClientSession, ConnectionTimeout, RequestTimeout
+from blacksheep.client import ClientSession, ConnectionTimeout, RequestTimeout
from . import FakePools
diff --git a/tests/conftest.py b/tests/conftest.py
index b1e1f6a6..e32ac2c8 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -2,8 +2,8 @@
import pytest
-from neoteroi.web.server.rendering.jinja2 import JinjaRenderer
-from neoteroi.web.settings.html import html_settings
+from blacksheep.server.rendering.jinja2 import JinjaRenderer
+from blacksheep.settings.html import html_settings
from tests.utils.application import FakeApplication
# configures default Jinja settings for tests
diff --git a/tests/test_application.py b/tests/test_application.py
index 47dfb738..2a60cc7d 100644
--- a/tests/test_application.py
+++ b/tests/test_application.py
@@ -10,15 +10,15 @@
import pkg_resources
import pytest
+from guardpost import AuthenticationHandler, Identity, User
from openapidocs.v3 import Info
from pydantic import BaseModel, ValidationError
+from rodi import Container, inject
-from neoteroi.auth import AuthenticationHandler, Identity, User
-from neoteroi.di import Container, inject
-from neoteroi.web import HTTPException, JSONContent, Request, Response, TextContent
-from neoteroi.web.contents import FormPart
-from neoteroi.web.server.application import Application, ApplicationSyncEvent
-from neoteroi.web.server.bindings import (
+from blacksheep import HTTPException, JSONContent, Request, Response, TextContent
+from blacksheep.contents import FormPart
+from blacksheep.server.application import Application, ApplicationSyncEvent
+from blacksheep.server.bindings import (
ClientInfo,
FromBytes,
FromCookie,
@@ -33,13 +33,13 @@
RequestUser,
ServerInfo,
)
-from neoteroi.web.server.di import di_scope_middleware
-from neoteroi.web.server.normalization import ensure_response
-from neoteroi.web.server.openapi.v3 import OpenAPIHandler
-from neoteroi.web.server.responses import status_code, text
-from neoteroi.web.server.security.hsts import HSTSMiddleware
-from neoteroi.web.testing.helpers import get_example_scope
-from neoteroi.web.testing.messages import MockReceive, MockSend
+from blacksheep.server.di import di_scope_middleware
+from blacksheep.server.normalization import ensure_response
+from blacksheep.server.openapi.v3 import OpenAPIHandler
+from blacksheep.server.responses import status_code, text
+from blacksheep.server.security.hsts import HSTSMiddleware
+from blacksheep.testing.helpers import get_example_scope
+from blacksheep.testing.messages import MockReceive, MockSend
from tests.utils.application import FakeApplication
from tests.utils.folder import ensure_folder
diff --git a/tests/test_auth.py b/tests/test_auth.py
index e1abde5b..f623d6e0 100644
--- a/tests/test_auth.py
+++ b/tests/test_auth.py
@@ -4,29 +4,29 @@
import jwt
import pkg_resources
import pytest
+from guardpost import AuthorizationContext, Identity, Policy, UnauthorizedError
+from guardpost.common import AuthenticatedRequirement
+from guardpost.jwks import JWKS, InMemoryKeysProvider, KeysProvider
from pytest import raises
+from rodi import Container
-from neoteroi.auth import AuthorizationContext, Identity, Policy, UnauthorizedError
-from neoteroi.auth.common import AuthenticatedRequirement
-from neoteroi.auth.jwks import JWKS, InMemoryKeysProvider, KeysProvider
-from neoteroi.di import Container
-from neoteroi.web.messages import Request
-from neoteroi.web.server.application import Application
-from neoteroi.web.server.authentication import (
+from blacksheep.messages import Request
+from blacksheep.server.application import Application
+from blacksheep.server.authentication import (
AuthenticateChallenge,
AuthenticationHandler,
)
-from neoteroi.web.server.authentication.jwt import JWTBearerAuthentication
-from neoteroi.web.server.authorization import (
+from blacksheep.server.authentication.jwt import JWTBearerAuthentication
+from blacksheep.server.authorization import (
AuthorizationWithoutAuthenticationError,
Requirement,
allow_anonymous,
auth,
get_www_authenticated_header_from_generic_unauthorized_error,
)
-from neoteroi.web.server.di import di_scope_middleware, register_http_context
-from neoteroi.web.testing.helpers import get_example_scope
-from neoteroi.web.testing.messages import MockReceive, MockSend
+from blacksheep.server.di import di_scope_middleware, register_http_context
+from blacksheep.testing.helpers import get_example_scope
+from blacksheep.testing.messages import MockReceive, MockSend
from tests.test_files_serving import get_folder_path
from tests.utils.application import FakeApplication
@@ -317,7 +317,7 @@ async def home():
@pytest.mark.asyncio
async def test_authorization_supports_allow_anonymous(app):
- from neoteroi.web.server.responses import text
+ from blacksheep.server.responses import text
app.use_authentication().add(MockNotAuthHandler())
diff --git a/tests/test_auth_cookie.py b/tests/test_auth_cookie.py
index 961c55e4..575bac14 100644
--- a/tests/test_auth_cookie.py
+++ b/tests/test_auth_cookie.py
@@ -2,11 +2,11 @@
from typing import Any
import pytest
+from guardpost import Identity
-from neoteroi.auth import Identity
-from neoteroi.web.messages import Request, Response
-from neoteroi.web.server.authentication.cookie import CookieAuthentication
-from neoteroi.web.server.dataprotection import generate_secret
+from blacksheep.messages import Request, Response
+from blacksheep.server.authentication.cookie import CookieAuthentication
+from blacksheep.server.dataprotection import generate_secret
def get_auth_cookie(handler: CookieAuthentication, data: Any) -> str:
diff --git a/tests/test_bindings.py b/tests/test_bindings.py
index 120ce8a2..19b36c3e 100644
--- a/tests/test_bindings.py
+++ b/tests/test_bindings.py
@@ -2,12 +2,12 @@
from uuid import UUID
import pytest
+from guardpost import Identity
from pytest import raises
+from rodi import Container
-from neoteroi.auth import Identity
-from neoteroi.di import Container
-from neoteroi.web import FormContent, FormPart, JSONContent, MultiPartFormData, Request
-from neoteroi.web.server.bindings import (
+from blacksheep import FormContent, FormPart, JSONContent, MultiPartFormData, Request
+from blacksheep.server.bindings import (
BadRequest,
Binder,
BinderAlreadyDefinedException,
@@ -32,7 +32,7 @@
TypeAliasAlreadyDefinedException,
get_binder_by_type,
)
-from neoteroi.web.url import URL
+from blacksheep.url import URL
JSONContentType = (b"Content-Type", b"application/json")
diff --git a/tests/test_contents.py b/tests/test_contents.py
index 86e70633..f0c805cd 100644
--- a/tests/test_contents.py
+++ b/tests/test_contents.py
@@ -2,8 +2,8 @@
import pytest
-from neoteroi.web import JSONContent, Request, StreamedContent
-from neoteroi.web.contents import (
+from blacksheep import JSONContent, Request, StreamedContent
+from blacksheep.contents import (
FormPart,
HTMLContent,
MultiPartFormData,
@@ -11,12 +11,12 @@
parse_www_form,
write_www_form_urlencoded,
)
-from neoteroi.web.multipart import (
+from blacksheep.multipart import (
get_boundary_from_header,
parse_content_disposition_values,
parse_multipart,
)
-from neoteroi.web.scribe import write_chunks, write_request_body_only
+from blacksheep.scribe import write_chunks, write_request_body_only
@pytest.mark.asyncio
diff --git a/tests/test_controllers.py b/tests/test_controllers.py
index 47bf962c..3658ed63 100644
--- a/tests/test_controllers.py
+++ b/tests/test_controllers.py
@@ -3,18 +3,18 @@
from typing import Optional
import pytest
-
-from neoteroi.auth import User
-from neoteroi.di import inject
-from neoteroi.web import Request, Response
-from neoteroi.web.server.application import Application
-from neoteroi.web.server.controllers import APIController, Controller, RoutesRegistry
-from neoteroi.web.server.responses import text
-from neoteroi.web.server.routing import RouteDuplicate
-from neoteroi.web.server.websocket import WebSocket
-from neoteroi.web.testing.helpers import get_example_scope
-from neoteroi.web.testing.messages import MockReceive, MockSend
-from neoteroi.web.utils import ensure_str
+from guardpost import User
+from rodi import inject
+
+from blacksheep import Request, Response
+from blacksheep.server.application import Application
+from blacksheep.server.controllers import APIController, Controller, RoutesRegistry
+from blacksheep.server.responses import text
+from blacksheep.server.routing import RouteDuplicate
+from blacksheep.server.websocket import WebSocket
+from blacksheep.testing.helpers import get_example_scope
+from blacksheep.testing.messages import MockReceive, MockSend
+from blacksheep.utils import ensure_str
from tests.test_files_serving import get_file_path
diff --git a/tests/test_cookies.py b/tests/test_cookies.py
index e8d8f4d4..1f3cb0a2 100644
--- a/tests/test_cookies.py
+++ b/tests/test_cookies.py
@@ -2,7 +2,7 @@
import pytest
-from neoteroi.web import (
+from blacksheep import (
Cookie,
CookieSameSiteMode,
datetime_from_cookie_format,
@@ -10,7 +10,7 @@
parse_cookie,
scribe,
)
-from neoteroi.web.cookies import CookieValueExceedsMaximumLength
+from blacksheep.cookies import CookieValueExceedsMaximumLength
COOKIES = [
(
diff --git a/tests/test_cors.py b/tests/test_cors.py
index def5436d..369ab83f 100644
--- a/tests/test_cors.py
+++ b/tests/test_cors.py
@@ -1,18 +1,18 @@
import pytest
-from neoteroi.web.exceptions import BadRequest
-from neoteroi.web.server.application import ApplicationAlreadyStartedCORSError
-from neoteroi.web.server.cors import (
+from blacksheep.exceptions import BadRequest
+from blacksheep.server.application import ApplicationAlreadyStartedCORSError
+from blacksheep.server.cors import (
CORSConfigurationError,
CORSPolicy,
CORSPolicyNotConfiguredError,
CORSStrategy,
NotRequestHandlerError,
)
-from neoteroi.web.server.responses import text
-from neoteroi.web.server.routing import Router
-from neoteroi.web.testing.helpers import get_example_scope
-from neoteroi.web.testing.messages import MockReceive, MockSend
+from blacksheep.server.responses import text
+from blacksheep.server.routing import Router
+from blacksheep.testing.helpers import get_example_scope
+from blacksheep.testing.messages import MockReceive, MockSend
def test_app_raises_type_error_for_cors_property(app):
diff --git a/tests/test_csrf.py b/tests/test_csrf.py
index 09dc203a..806fdae6 100644
--- a/tests/test_csrf.py
+++ b/tests/test_csrf.py
@@ -2,16 +2,16 @@
import pytest
-from neoteroi.web.contents import write_www_form_urlencoded
-from neoteroi.web.messages import Response
-from neoteroi.web.server.controllers import Controller
-from neoteroi.web.server.csrf import ignore_anti_forgery, use_anti_forgery
-from neoteroi.web.server.rendering.jinja2 import AntiForgeryBaseExtension, JinjaRenderer
-from neoteroi.web.server.responses import no_content, view, view_async
-from neoteroi.web.server.routing import RoutesRegistry
-from neoteroi.web.settings.html import html_settings
-from neoteroi.web.testing.helpers import get_example_scope
-from neoteroi.web.testing.messages import MockReceive, MockSend
+from blacksheep.contents import write_www_form_urlencoded
+from blacksheep.messages import Response
+from blacksheep.server.controllers import Controller
+from blacksheep.server.csrf import ignore_anti_forgery, use_anti_forgery
+from blacksheep.server.rendering.jinja2 import AntiForgeryBaseExtension, JinjaRenderer
+from blacksheep.server.responses import no_content, view, view_async
+from blacksheep.server.routing import RoutesRegistry
+from blacksheep.settings.html import html_settings
+from blacksheep.testing.helpers import get_example_scope
+from blacksheep.testing.messages import MockReceive, MockSend
from tests.utils.application import FakeApplication
@@ -147,7 +147,7 @@ async def home():
text = await app.response.text()
assert text is not None
assert (
- "neoteroi.web.server.csrf.MissingRequestContextError: The request context is "
+ "blacksheep.server.csrf.MissingRequestContextError: The request context is "
"missing from the render call. Pass the request object to the context of the "
"template."
) in text
diff --git a/tests/test_dataprotection.py b/tests/test_dataprotection.py
index e06834ae..92f62ae9 100644
--- a/tests/test_dataprotection.py
+++ b/tests/test_dataprotection.py
@@ -3,7 +3,7 @@
import pytest
from itsdangerous import BadSignature
-from neoteroi.web.server.dataprotection import generate_secret, get_keys, get_serializer
+from blacksheep.server.dataprotection import generate_secret, get_keys, get_serializer
def test_get_keys_creates_default_keys():
diff --git a/tests/test_env.py b/tests/test_env.py
index 0397395f..30347d9e 100644
--- a/tests/test_env.py
+++ b/tests/test_env.py
@@ -1,6 +1,6 @@
import os
-from neoteroi.web.server.env import EnvironmentSettings
+from blacksheep.server.env import EnvironmentSettings
def test_env_settings():
diff --git a/tests/test_files_handler.py b/tests/test_files_handler.py
index 98173784..acff7e7d 100644
--- a/tests/test_files_handler.py
+++ b/tests/test_files_handler.py
@@ -6,7 +6,7 @@
import pytest
-from neoteroi.web.common.files.asyncfs import FileContext, FilesHandler
+from blacksheep.common.files.asyncfs import FileContext, FilesHandler
@pytest.fixture()
diff --git a/tests/test_files_serving.py b/tests/test_files_serving.py
index 9ca63262..68f8e53a 100644
--- a/tests/test_files_serving.py
+++ b/tests/test_files_serving.py
@@ -7,24 +7,25 @@
import pytest
from essentials.folders import get_file_extension
-from neoteroi.web import Request
-from neoteroi.web.common.files.asyncfs import FileContext, FilesHandler
-from neoteroi.web.exceptions import BadRequest, InvalidArgument
-from neoteroi.web.ranges import Range, RangePart
-from neoteroi.web.server.files import (
+from blacksheep import Request
+from blacksheep.common.files.asyncfs import FileContext, FilesHandler
+from blacksheep.exceptions import BadRequest, InvalidArgument
+from blacksheep.ranges import Range, RangePart
+from blacksheep.server.files import (
FileInfo,
RangeNotSatisfiable,
+ ServeFilesOptions,
_get_requested_range,
get_default_extensions,
get_range_file_getter,
validate_source_path,
)
-from neoteroi.web.server.files.dynamic import get_response_for_file
-from neoteroi.web.server.files.static import get_response_for_static_content
-from neoteroi.web.server.responses import text
-from neoteroi.web.testing.helpers import get_example_scope
-from neoteroi.web.testing.messages import MockReceive, MockSend
-from neoteroi.web.utils.aio import get_running_loop
+from blacksheep.server.files.dynamic import get_response_for_file
+from blacksheep.server.files.static import get_response_for_static_content
+from blacksheep.server.responses import text
+from blacksheep.testing.helpers import get_example_scope
+from blacksheep.testing.messages import MockReceive, MockSend
+from blacksheep.utils.aio import get_running_loop
def get_folder_path(folder_name: str) -> str:
@@ -337,6 +338,25 @@ async def test_serve_files_no_discovery(app):
assert response.status == 404
+@pytest.mark.asyncio
+async def test_serve_files_deprecated_serve_files_options(files2_index_contents, app):
+ with pytest.deprecated_call():
+ app.serve_files(ServeFilesOptions(get_folder_path("files2"))) # type: ignore
+
+ await app.start()
+
+ scope = get_example_scope("GET", "/", [])
+ await app(
+ scope,
+ MockReceive(),
+ MockSend(),
+ )
+
+ response = app.response
+ assert response.status == 200
+ assert files2_index_contents == await response.read()
+
+
@pytest.mark.asyncio
async def test_serve_files_fallback_document(files2_index_contents: bytes, app):
"""Feature used to serve SPAs that use HTML5 History API"""
diff --git a/tests/test_forwarding.py b/tests/test_forwarding.py
index 10d3f851..dec1d621 100644
--- a/tests/test_forwarding.py
+++ b/tests/test_forwarding.py
@@ -2,15 +2,15 @@
import pytest
-from neoteroi.web.server.remotes.forwarding import (
+from blacksheep.server.remotes.forwarding import (
ForwardedHeaderEntry,
ForwardedHeadersMiddleware,
XForwardedHeadersMiddleware,
parse_forwarded_header,
)
-from neoteroi.web.server.remotes.hosts import TrustedHostsMiddleware
-from neoteroi.web.testing.helpers import get_example_scope
-from neoteroi.web.testing.messages import MockReceive, MockSend
+from blacksheep.server.remotes.hosts import TrustedHostsMiddleware
+from blacksheep.testing.helpers import get_example_scope
+from blacksheep.testing.messages import MockReceive, MockSend
from tests.utils.application import FakeApplication
diff --git a/tests/test_headers.py b/tests/test_headers.py
index 0006aef8..0dcae347 100644
--- a/tests/test_headers.py
+++ b/tests/test_headers.py
@@ -1,6 +1,6 @@
import pytest
-from neoteroi.web import Header, Headers
+from blacksheep import Header, Headers
@pytest.mark.parametrize(
diff --git a/tests/test_multipart.py b/tests/test_multipart.py
index 304cc785..dea55ab3 100644
--- a/tests/test_multipart.py
+++ b/tests/test_multipart.py
@@ -1,6 +1,6 @@
import pytest
-from neoteroi.web.multipart import (
+from blacksheep.multipart import (
FormPart,
_remove_last_crlf,
parse_multipart,
diff --git a/tests/test_normalization.py b/tests/test_normalization.py
index 35d52dd9..7a013f74 100644
--- a/tests/test_normalization.py
+++ b/tests/test_normalization.py
@@ -4,12 +4,12 @@
from typing import List, Optional, Sequence, Union
import pytest
+from guardpost import Identity, User
from pytest import raises
+from rodi import Container, Services, inject
-from neoteroi.auth import Identity, User
-from neoteroi.di import Container, Services, inject
-from neoteroi.web import Request
-from neoteroi.web.server.bindings import (
+from blacksheep import Request
+from blacksheep.server.bindings import (
Binder,
BoundValue,
ExactBinder,
@@ -26,7 +26,7 @@
RouteBinder,
ServiceBinder,
)
-from neoteroi.web.server.normalization import (
+from blacksheep.server.normalization import (
AmbiguousMethodSignatureError,
NormalizationError,
RouteBinderMismatch,
@@ -37,7 +37,7 @@
normalize_handler,
normalize_middleware,
)
-from neoteroi.web.server.routing import Route
+from blacksheep.server.routing import Route
class Pet:
diff --git a/tests/test_openapi_docstrings.py b/tests/test_openapi_docstrings.py
index 94f80926..2dd2babd 100644
--- a/tests/test_openapi_docstrings.py
+++ b/tests/test_openapi_docstrings.py
@@ -2,8 +2,8 @@
import pytest
-from neoteroi.web.server.openapi.common import ParameterInfo
-from neoteroi.web.server.openapi.docstrings import (
+from blacksheep.server.openapi.common import ParameterInfo
+from blacksheep.server.openapi.docstrings import (
DocstringInfo,
EpytextDialect,
GoogleDocDialect,
diff --git a/tests/test_openapi_v3.py b/tests/test_openapi_v3.py
index ec1059cd..805bcdf9 100644
--- a/tests/test_openapi_v3.py
+++ b/tests/test_openapi_v3.py
@@ -11,25 +11,25 @@
from pydantic.generics import GenericModel
from pydantic.types import NegativeFloat, PositiveInt, condecimal, confloat, conint
-from neoteroi.web.server.application import Application
-from neoteroi.web.server.bindings import FromForm
-from neoteroi.web.server.openapi.common import (
+from blacksheep.server.application import Application
+from blacksheep.server.bindings import FromForm
+from blacksheep.server.openapi.common import (
ContentInfo,
EndpointDocs,
OpenAPIEndpointException,
ResponseInfo,
)
-from neoteroi.web.server.openapi.exceptions import (
+from blacksheep.server.openapi.exceptions import (
DuplicatedContentTypeDocsException,
UnsupportedUnionTypeException,
)
-from neoteroi.web.server.openapi.v3 import (
+from blacksheep.server.openapi.v3 import (
DataClassTypeHandler,
OpenAPIHandler,
PydanticModelTypeHandler,
check_union,
)
-from neoteroi.web.server.routing import RoutesRegistry
+from blacksheep.server.routing import RoutesRegistry
T = TypeVar("T")
U = TypeVar("U")
diff --git a/tests/test_pathutils.py b/tests/test_pathutils.py
index 353d1846..f706a96f 100644
--- a/tests/test_pathutils.py
+++ b/tests/test_pathutils.py
@@ -1,6 +1,6 @@
import pytest
-from neoteroi.web.common.files.pathsutils import (
+from blacksheep.common.files.pathsutils import (
get_file_extension_from_name,
get_mime_type_from_name,
)
diff --git a/tests/test_ranges.py b/tests/test_ranges.py
index 98ac24de..18962b5d 100644
--- a/tests/test_ranges.py
+++ b/tests/test_ranges.py
@@ -1,6 +1,6 @@
import pytest
-from neoteroi.web.ranges import InvalidRangeValue, Range, RangePart
+from blacksheep.ranges import InvalidRangeValue, Range, RangePart
@pytest.mark.parametrize(
diff --git a/tests/test_requests.py b/tests/test_requests.py
index 54ec88a2..fc26e59c 100644
--- a/tests/test_requests.py
+++ b/tests/test_requests.py
@@ -1,17 +1,17 @@
import pytest
-from neoteroi.web import Content, Request, scribe
-from neoteroi.web.contents import FormPart, MultiPartFormData
-from neoteroi.web.exceptions import BadRequestFormat
-from neoteroi.web.messages import get_absolute_url_to_path, get_request_absolute_url
-from neoteroi.web.scribe import write_small_request
-from neoteroi.web.server.asgi import (
+from blacksheep import Content, Request, scribe
+from blacksheep.contents import FormPart, MultiPartFormData
+from blacksheep.exceptions import BadRequestFormat
+from blacksheep.messages import get_absolute_url_to_path, get_request_absolute_url
+from blacksheep.scribe import write_small_request
+from blacksheep.server.asgi import (
get_request_url,
get_request_url_from_scope,
incoming_request,
)
-from neoteroi.web.testing.helpers import get_example_scope
-from neoteroi.web.url import URL
+from blacksheep.testing.helpers import get_example_scope
+from blacksheep.url import URL
def test_request_supports_dynamic_attributes():
diff --git a/tests/test_responses.py b/tests/test_responses.py
index 233e9468..5916825f 100644
--- a/tests/test_responses.py
+++ b/tests/test_responses.py
@@ -7,12 +7,12 @@
import pytest
-from neoteroi.web import Content, Cookie, Response, scribe
-from neoteroi.web.server.controllers import (
+from blacksheep import Content, Cookie, Response, scribe
+from blacksheep.server.controllers import (
CannotDetermineDefaultViewNameError,
Controller,
)
-from neoteroi.web.server.responses import (
+from blacksheep.server.responses import (
ContentDispositionType,
accepted,
bad_request,
@@ -35,9 +35,9 @@
text,
unauthorized,
)
-from neoteroi.web.server.routing import RoutesRegistry
-from neoteroi.web.testing.helpers import get_example_scope
-from neoteroi.web.testing.messages import MockReceive, MockSend
+from blacksheep.server.routing import RoutesRegistry
+from blacksheep.testing.helpers import get_example_scope
+from blacksheep.testing.messages import MockReceive, MockSend
from tests.test_files_serving import get_file_path
STATUS_METHODS_OPTIONAL_BODY = [
diff --git a/tests/test_router.py b/tests/test_router.py
index 0de14504..a8b4e60c 100644
--- a/tests/test_router.py
+++ b/tests/test_router.py
@@ -1,7 +1,7 @@
import pytest
-from neoteroi.web.server.application import Application
-from neoteroi.web.server.routing import (
+from blacksheep.server.application import Application
+from blacksheep.server.routing import (
InvalidValuePatternName,
MountRegistry,
Route,
diff --git a/tests/test_sessions.py b/tests/test_sessions.py
index 1b79ee31..b811ae20 100644
--- a/tests/test_sessions.py
+++ b/tests/test_sessions.py
@@ -2,12 +2,12 @@
import pytest
-from neoteroi.web.cookies import parse_cookie
-from neoteroi.web.messages import Request
-from neoteroi.web.server.responses import text
-from neoteroi.web.sessions import JSONSerializer, Session, SessionMiddleware
-from neoteroi.web.testing.helpers import get_example_scope
-from neoteroi.web.testing.messages import MockReceive, MockSend
+from blacksheep.cookies import parse_cookie
+from blacksheep.messages import Request
+from blacksheep.server.responses import text
+from blacksheep.sessions import JSONSerializer, Session, SessionMiddleware
+from blacksheep.testing.helpers import get_example_scope
+from blacksheep.testing.messages import MockReceive, MockSend
def test_friendly_exception_for_request_without_session():
diff --git a/tests/test_templating.py b/tests/test_templating.py
index ac396bc1..ca3b8829 100644
--- a/tests/test_templating.py
+++ b/tests/test_templating.py
@@ -4,12 +4,12 @@
import pytest
from pydantic import BaseModel
-from neoteroi.web.server.controllers import Controller, RoutesRegistry
-from neoteroi.web.server.rendering.jinja2 import get_template_name
-from neoteroi.web.server.responses import view, view_async
-from neoteroi.web.settings.html import html_settings
-from neoteroi.web.testing.helpers import get_example_scope
-from neoteroi.web.testing.messages import MockReceive, MockSend
+from blacksheep.server.controllers import Controller, RoutesRegistry
+from blacksheep.server.rendering.jinja2 import get_template_name
+from blacksheep.server.responses import view, view_async
+from blacksheep.settings.html import html_settings
+from blacksheep.testing.helpers import get_example_scope
+from blacksheep.testing.messages import MockReceive, MockSend
from tests.utils.application import FakeApplication
diff --git a/tests/test_testing.py b/tests/test_testing.py
index 9ff7221b..d718a7e7 100644
--- a/tests/test_testing.py
+++ b/tests/test_testing.py
@@ -2,14 +2,14 @@
import pytest
-from neoteroi.web import Content
-from neoteroi.web.contents import JSONContent
-from neoteroi.web.server.application import Application
-from neoteroi.web.server.bindings import FromHeader
-from neoteroi.web.server.controllers import Controller, RoutesRegistry
-from neoteroi.web.server.responses import Response
-from neoteroi.web.testing import AbstractTestSimulator, TestClient
-from neoteroi.web.testing.helpers import (
+from blacksheep import Content
+from blacksheep.contents import JSONContent
+from blacksheep.server.application import Application
+from blacksheep.server.bindings import FromHeader
+from blacksheep.server.controllers import Controller, RoutesRegistry
+from blacksheep.server.responses import Response
+from blacksheep.testing import AbstractTestSimulator, TestClient
+from blacksheep.testing.helpers import (
CookiesType,
HeadersType,
QueryType,
diff --git a/tests/test_url.py b/tests/test_url.py
index 5d2ea429..53446543 100644
--- a/tests/test_url.py
+++ b/tests/test_url.py
@@ -1,6 +1,6 @@
import pytest
-from neoteroi.web.url import URL, InvalidURL
+from blacksheep.url import URL, InvalidURL
def test_empty_url():
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 64f4df90..1c0eb9e2 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -2,7 +2,7 @@
import pytest
-from neoteroi.web.utils import ensure_bytes, ensure_str, join_fragments
+from blacksheep.utils import ensure_bytes, ensure_str, join_fragments
@pytest.mark.parametrize(
diff --git a/tests/test_websocket.py b/tests/test_websocket.py
index ae58e67d..4b95a387 100644
--- a/tests/test_websocket.py
+++ b/tests/test_websocket.py
@@ -1,14 +1,14 @@
import pytest
-from neoteroi.web.server.bindings import FromHeader
-from neoteroi.web.server.websocket import (
+from blacksheep.server.bindings import FromHeader
+from blacksheep.server.websocket import (
InvalidWebSocketStateError,
MessageMode,
WebSocket,
WebSocketDisconnectError,
WebSocketState,
)
-from neoteroi.web.testing.messages import MockReceive, MockSend
+from blacksheep.testing.messages import MockReceive, MockSend
from tests.utils.application import FakeApplication
diff --git a/tests/utils/application.py b/tests/utils/application.py
index ae9f406a..e5810785 100644
--- a/tests/utils/application.py
+++ b/tests/utils/application.py
@@ -1,7 +1,7 @@
from typing import Optional
-from neoteroi.web.messages import Request, Response
-from neoteroi.web.server import Application
+from blacksheep.messages import Request, Response
+from blacksheep.server import Application
class FakeApplication(Application):