- exception weaver.wps_restapi.utils.HTTPHeadFileResponse(code: Optional[weaver.typedefs.HeadersType] = 200, headers: Any = None, **kwargs)
Provides additional header handing when returning a response to HTTP HEAD request.
When returning from HTTP HEAD, the body contents are omitted from the response. The response MUST NOT contain the body contents, but the HTTP headers SHOULD be identical to the corresponding HTTP GET request.
Even though no content is provided for HEAD response,
204SHOULD NOT be used since it must emulate the GET response that would contain the content.
pyramidincorrectly drops important headers such as
Content-Lengththat should be reported as if the file was returned when the represented entity is a file, although no content is actually present. When instead the body is omitted (
HTTPException.prepare()method also incorrectly overrides the
Content-Lengthalso gets recalculated when the content iterator is created from the initialization parameters. This class takes care of all these edge cases to properly report content headers of HEAD requests although none is provided.
Initialize self. See help(type(self)) for accurate signature.
- prepare(self, environ)
No contents for HEAD request.
- weaver.wps_restapi.utils.wps_restapi_base_path(container: weaver.typedefs.AnySettingsContainer) str
- weaver.wps_restapi.utils.get_wps_restapi_base_url(container: weaver.typedefs.AnySettingsContainer) str
- weaver.wps_restapi.utils.get_schema_ref(schema: colander.SchemaNode, container: Optional[weaver.typedefs.AnySettingsContainer] = None, ref_type: str = '$schema', ref_name: True = True) Dict[str, str]
Generates the JSON OpenAPI schema reference relative to the current Weaver instance.
The provided schema should be one of the items listed in
/jsonendpoint. No validation is accomplished to avoid long processing of all references.
weaver.schema_urlis set, this value will be used direct as fully-defined base URL. This could be used to refer to a static endpoint where schemas are hosted. Otherwise, the current Web Application resolved location is employed with JSON OpenAPI path.
schema – schema-node instance or type for which to generate the OpenAPI reference.
container – application settings to retrieve the base URL of the schema location.
ref_type – key employed to form the reference (e.g.: “$schema”, “$ref”, “@schema”, etc.)
ref_name – indicate if the plain name should also be included under field
OpenAPI schema reference
- weaver.wps_restapi.utils.handle_schema_validation(schema: Optional[colander.SchemaNode] = None) Callable
Convert a schema validation error into an HTTP error with error details about the failure.
schema – If provided, document this schema as the reference of the failed schema validation.
HTTPBadRequest – If any schema validation error occurs when handling the decorated function.