class HttpServer(object):
The HTTP server for the CSE.
| Method | add |
Add an endpoint to the Flask application. |
| Method | configure |
Configure the HTTP server with the given configuration. |
| Method | get |
Get all registered HTTP endpoints. |
| Method | handle |
Handle the authentication for the current request. |
| Method | handle |
Handle a DELETE request. |
| Method | handle |
Handle a GET request. |
| Method | handle |
Support PATCH instead of DELETE for http/1.0. |
| Method | handle |
Handle a POST request. |
| Method | handle |
Handle a PUT request. |
| Method | init |
Start the HTTP server. This sets up the Flask application, configures CORS, adds endpoints, and initializes the web UI. |
| Method | pause |
Stop handling requests. |
| Method | run |
Run the http server in a separate thread. |
| Method | send |
Send an http request. |
| Method | shutdown |
Shutting down the http server. |
| Method | unpause |
Continue handling requests. |
| Method | validate |
Validate the configuration for the HTTP server. |
| Class Variable | __slots__ |
The slots for the HttpServer class to optimize memory usage. |
| Class Variable | cse |
Injected function to shut down the CSE. |
| Class Variable | operation2method |
A mapping of operations to the corresponding HTTP methods. |
| Class Variable | request |
Injected RequestManager instance. |
| Class Variable | security |
Injected SecurityManager instance. |
| Instance Variable | background |
The background worker for the HTTP server. |
| Instance Variable | flask |
The Flask application instance. |
| Instance Variable | http |
The background worker for the HTTP server. |
| Instance Variable | is |
Whether the HTTP server is stopped. |
| Instance Variable | server |
The server's ID for HTTP response headers. |
| Method | _dissect |
Dissect an HTTP request. Combine headers and contents into a single structure. Result is returned in Result.request. |
| Method | _handle |
Get and check all the necessary information from the request and build the internal strutures. Then, depending on the operation, call the associated request handler. |
| Method | _has |
Check if the request has a content type that is supported by the CSE. This is used to determine if the request can be processed. |
| Method | _prepare |
Prepare the response for a request. If request is given then set it for the response. |
| Method | _run |
Run the http server. This method is run in a separate thread. It starts the Flask application and serves it. |
| Class Variable | _hdr |
Regex to check if the request has a content type that is supported by the CSE. |
| Instance Variable | _response |
Additional headers for HTTP responses. |
str | None = None, endpoint_name: str | None = None, handler: FlaskHandler | None = None, methods: list[ str] | None = None, strictSlashes: bool | None = True) -> str:
¶
Add an endpoint to the Flask application.
| Parameters | |
endpoint:str | None | The endpoint URL. |
endpointstr | None | The name of the endpoint. |
handler:FlaskHandler | None | The handler function for the endpoint. |
methods:list[ | The HTTP methods allowed for this endpoint. |
strictbool | None | Whether to enforce strict slashes in the URL. |
| Returns | |
str | The path of the registered endpoint. |
Configure the HTTP server with the given configuration.
| Parameters | |
config:Configuration | The configuration to use for the HTTP server. |
Get all registered HTTP endpoints.
| Returns | |
list[ | List of dictionaries containing endpoint information. |
Handle the authentication for the current request.
| Returns | |
AuthorizationResult | Enum value for the authentication result. |
Handle a DELETE request.
| Parameters | |
path:str | None | The path of the request. |
| Returns | |
Response | Undocumented |
Support PATCH instead of DELETE for http/1.0.
| Parameters | |
path:str | None | The path of the request. |
| Returns | |
Response | Undocumented |
Start the HTTP server. This sets up the Flask application, configures CORS, adds endpoints, and initializes the web UI.
Validate the configuration for the HTTP server.
| Parameters | |
config:Configuration | The configuration to validate. |
Dissect an HTTP request. Combine headers and contents into a single structure. Result is returned in Result.request.
str, operation: Operation, authResult: AuthorizationResult) -> Response:
¶
Get and check all the necessary information from the request and build the internal strutures. Then, depending on the operation, call the associated request handler.
Check if the request has a content type that is supported by the CSE. This is used to determine if the request can be processed.
| Returns | |
bool | True if the request has a content type that is supported, False otherwise. |
Result, originalRequest: CSERequest | None = None) -> Response:
¶
Prepare the response for a request. If request is given then
set it for the response.