pyrit.prompt_target.HTTPXAPITarget#
- class HTTPXAPITarget(*, http_url: str, method: Literal['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'] = 'POST', file_path: str | None = None, json_data: dict | None = None, form_data: dict | None = None, params: dict | None = None, headers: dict | None = None, http2: bool | None = None, callback_function: Callable | None = None, max_requests_per_minute: int | None = None, **httpx_client_kwargs: Any)[source]#
Bases:
HTTPTargetA subclass of HTTPTarget that only does “API mode” (no raw HTTP request). This is a simpler approach for uploading files or sending JSON/form data.
Additionally, if ‘file_path’ is not provided in the constructor, we attempt to pull it from the prompt’s converted_value, assuming it’s a local file path generated by a PromptConverter (like PDFConverter).
- __init__(*, http_url: str, method: Literal['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'] = 'POST', file_path: str | None = None, json_data: dict | None = None, form_data: dict | None = None, params: dict | None = None, headers: dict | None = None, http2: bool | None = None, callback_function: Callable | None = None, max_requests_per_minute: int | None = None, **httpx_client_kwargs: Any) None[source]#
Force the parent ‘HTTPTarget’ to skip raw http_request logic by setting http_request=None.
Methods
__init__(*, http_url[, method, file_path, ...])Force the parent 'HTTPTarget' to skip raw http_request logic by setting http_request=None.
dispose_db_engine()Dispose database engine to release database connections and resources.
get_identifier()parse_raw_http_request(http_request)Parses the HTTP request string into a dictionary of headers
send_prompt_async(**kwargs)Sends a normalized prompt async to the prompt target.
set_model_name(*, model_name)Set the model name for this target.
with_client(client, http_request[, ...])Alternative constructor that accepts a pre-configured httpx client.
Attributes
- async send_prompt_async(**kwargs)#
Sends a normalized prompt async to the prompt target.