Divooka.DSL.HTTPRequest
Divooka.DSL.HTTPRequest.Helpers.HTTPHelper
Some one-shot operations.
Divooka.DSL.HTTPRequest.Helpers.JsonElementExtensions.ToObject()
Remarks
This is more meaningful than just do `JsonElement.Deserialize<object>()` which returns still a JSON construct with ValueKind etc.
References
See the main PR responsible for this: https://github.com/Methodox-Technologies/Parcel_NExT/pull/237
Divooka.DSL.HTTPRequest.Helpers.JsonAccessor.QueryString()
Return the requested element as a string (or null if not found).
For string-typed JSON values, that string is returned directly.
For other types (object/array/number/bool), we return their JSON text.
Parameters
| Name | Description | Default |
|---|---|---|
json |
||
path |
Returns
Return value will be formatted.
Divooka.DSL.HTTPRequest.Helpers.JsonAccessor.QueryObject()
Return the requested element as a plain C# object (e.g.
List<object>, Dictionary<string,object>, strings, etc.).
For arrays, you'll get a List<object> tree; for objects, Dictionary<string, object>; etc.
Divooka.DSL.HTTPRequest.Helpers.JsonAccessor.TryProcessSegment()
Processes a single segment (like "time[0]" or "[1][2]") and advances 'current'.
Divooka.DSL.HTTPRequest.Helpers.StressTester.StressTest()
Main entry point. This function performs the stress test.
It issues the specified number of requests either sequentially or in parallel,
logs each communication to a temporary file, collects timing and resource usage metrics,
and finally generates a markdown report using a template with placeholder tokens.
Remarks
For local test: gather CPU, memory
Gather errors
Divooka.DSL.HTTPRequest.Helpers.StressTester.GenerateReport()
Helper function that replaces placeholders in a template string with actual metric values.
Divooka.DSL.HTTPRequest.Main.WebAPITester
Provides methods for testing web API functionality, including sending HTTP requests,
stress testing, code generation, URL creation, header assembly, and more.
Divooka.DSL.HTTPRequest.Main.WebAPITester.RequestMethod
Specifies the HTTP request methods.
Divooka.DSL.HTTPRequest.Main.WebAPITester.RequestMethod.GET
Represents an HTTP GET request.
Divooka.DSL.HTTPRequest.Main.WebAPITester.RequestMethod.HEAD
Represents an HTTP HEAD request, similar to GET but without the response body.
Divooka.DSL.HTTPRequest.Main.WebAPITester.RequestMethod.POST
Represents an HTTP POST request.
Divooka.DSL.HTTPRequest.Main.WebAPITester.RequestMethod.PUT
Represents an HTTP PUT request, used to update or create a resource at a specific URI.
Divooka.DSL.HTTPRequest.Main.WebAPITester.RequestMethod.DELETE
Represents an HTTP DELETE request, used to remove a resource from a server.
Divooka.DSL.HTTPRequest.Main.WebAPITester.RequestMethod.CONNECT
Represents an HTTP CONNECT request, used to establish a tunnel to a server.
Divooka.DSL.HTTPRequest.Main.WebAPITester.RequestMethod.OPTIONS
Represents an HTTP OPTIONS request, used to describe the communication options for a resource.
Divooka.DSL.HTTPRequest.Main.WebAPITester.RequestMethod.TRACE
Represents an HTTP TRACE request, used for debugging by echoing back the received request.
Divooka.DSL.HTTPRequest.Main.WebAPITester.RequestMethod.PATCH
Represents an HTTP PATCH request, used to apply partial modifications to a resource.
Divooka.DSL.HTTPRequest.Main.WebAPITester.ContentType
Specifies the content type of the HTTP request body.
Divooka.DSL.HTTPRequest.Main.WebAPITester.ContentType.Plain
Plain text content.
Divooka.DSL.HTTPRequest.Main.WebAPITester.ContentType.Json
JSON formatted content.
Divooka.DSL.HTTPRequest.Main.WebAPITester.ContentType.XML
XML formatted content
Divooka.DSL.HTTPRequest.Main.WebAPITester.ContentType.FormUrlEncoded
Form url encoded content.
Divooka.DSL.HTTPRequest.Main.WebAPITester.ContentType.MultipartForm
For form data with binary payloads e.g. files.
Remarks
TODO: Pending implementation. For reference, see OpenAIHelper.TranscribeAudio and https://chatgpt.com/share/67d228f4-4da4-8004-9c4c-5a92687590cb
Divooka.DSL.HTTPRequest.Main.WebAPITester.FilePart
Represents a binary part in a multipart/form-data body.
Divooka.DSL.HTTPRequest.Main.WebAPITester.FilePart.#ctor()
Represents a binary part in a multipart/form-data body.
Divooka.DSL.HTTPRequest.Main.WebAPITester._client
1 client for the whole process
Remarks
Avoids socket exhaustion and greatly improves throughput.
No need to dispose.
Divooka.DSL.HTTPRequest.Main.WebAPITester.SendRequest()
Sends an HTTP request using the specified method, URL, headers, and body.
Parameters
| Name | Description | Default |
|---|---|---|
method |
The HTTP method to use. | |
url |
The URL to which the request is sent. If multiline string is given, we automatically format it, assuming first line is base address (this allows skipping two nodes aka. CreateParameters and MakeURL). | |
headers |
Optional headers to include in the request. It's exposed as array here for Divooka coercion to work on multiple inputs. | |
body |
The request body as a string. | |
bodyType |
The content type of the request body. |
Returns
The response content as a byte array.
Divooka.DSL.HTTPRequest.Main.WebAPITester.StressTest()
Performs a stress test by repeatedly sending an HTTP request.
Parameters
| Name | Description | Default |
|---|---|---|
repeat |
The number of times to repeat the request. | |
method |
The HTTP method to use. | |
url |
The URL to which the request is sent. | |
headers |
Optional headers to include in the request. | |
body |
The request body as a string. | |
bodyType |
The content type of the request body. | |
parallel |
Indicates whether the requests should be sent in parallel. |
Returns
A string result from the stress test.
Divooka.DSL.HTTPRequest.Main.WebAPITester.MakeURL()
Creates a URL by combining the base URL, an endpoint, and optional query parameters.
Parameters
| Name | Description | Default |
|---|---|---|
base |
The base URL. | |
endpoint |
The endpoint to append to the base URL. | |
paremters |
Optional query parameters as a dictionary. |
Returns
A string representing the complete URL.
Divooka.DSL.HTTPRequest.Main.WebAPITester.UserAgent()
Creates a header dictionary with a User-Agent entry.
Parameters
| Name | Description | Default |
|---|---|---|
agent |
The user agent string. |
Returns
A dictionary containing the User-Agent header.
Divooka.DSL.HTTPRequest.Main.WebAPITester.BearerToken()
Creates a header dictionary with a Bearer token for authorization.
Parameters
| Name | Description | Default |
|---|---|---|
token |
The bearer token. |
Returns
A dictionary containing the Authorization header.
Divooka.DSL.HTTPRequest.Main.WebAPITester.Accepts()
E.g. "Accept: application/json"
Remarks
We use generic headers, no need for HTTPClient.DefaultRequestHeaders.Accept() function
TODO: Support multiple accept types.
Returns
A dictionary containing the accept type.
Divooka.DSL.HTTPRequest.Main.WebAPITester.CustomAPIKey()
E.g. "X-Subscription-Token: <YOUR_API_KEY>" from Brave API.
Parameters
| Name | Description | Default |
|---|---|---|
key |
Header key name | |
value |
Header value |
Returns
A dictionary containing the Custom API key.
Divooka.DSL.HTTPRequest.Main.WebAPITester.CustomHeader()
Anything generic.
Parameters
| Name | Description | Default |
|---|---|---|
key |
Header key name | |
value |
Header value |
Returns
A dictionary containing the header item.
Divooka.DSL.HTTPRequest.Main.WebAPITester.CreateParameters()
Creates a dictionary from text where each line contains a key and value separated by a colon.
Remarks
Also useful for headers.
Parameters
| Name | Description | Default |
|---|---|---|
text |
The input text containing key-value pairs. |
Returns
A dictionary created from the provided text.
Divooka.DSL.HTTPRequest.Main.WebAPITester.ToJSON()
Converts YAML formatted text to JSON.
Parameters
| Name | Description | Default |
|---|---|---|
yamlText |
The YAML formatted text. |
Returns
A string containing the JSON representation.
Divooka.DSL.HTTPRequest.Main.WebAPITester.Query()
Queries a JSON preview using the specified JSON path.
Parameters
| Name | Description | Default |
|---|---|---|
previous |
The previous JSON preview. | |
path |
The JSON path query string. |
Returns
A new JSON preview containing the queried result.
Divooka.DSL.HTTPRequest.Main.WebAPITester.PreviewPlainText()
Creates an plain text preview from the given byte array.
Parameters
| Name | Description | Default |
|---|---|---|
data |
The plain text data as a byte array. |
Returns
A PlainTextPreview instance.
Divooka.DSL.HTTPRequest.Main.WebAPITester.PreviewHTML()
Creates an HTML preview from the given byte array.
Parameters
| Name | Description | Default |
|---|---|---|
data |
The HTML data as a byte array. |
Returns
An HTMLPreview instance.
Divooka.DSL.HTTPRequest.Main.WebAPITester.PreviewWebsite()
Creates an preview from the given byte array as HTML website.
Parameters
| Name | Description | Default |
|---|---|---|
data |
The HTML (string) data as a byte array. |
Returns
An WebsitePreview instance.
Divooka.DSL.HTTPRequest.Main.WebAPITester.PreviewJSON()
Creates a JSON preview from the given byte array.
Parameters
| Name | Description | Default |
|---|---|---|
data |
The JSON data as a byte array. | |
formatting |
Indicates whether formatting should be applied. |
Returns
A JSONPreview instance.
Divooka.DSL.HTTPRequest.Main.WebAPITester.PreviewPNG()
Creates a image preview from the given byte array (representing png files).
Parameters
| Name | Description | Default |
|---|---|---|
data |
The image data as a byte array. |
Returns
A ImagePreview instance (for PnG only at this moment).
Divooka.DSL.HTTPRequest.Main.WebAPITester.GetMimeType()
Maps the custom ContentType enum to a MIME type string.
Parameters
| Name | Description | Default |
|---|---|---|
type |
Content type enum. |
Returns
String representation of the MIME type.
Divooka.DSL.HTTPRequest.Main.WebAPITester.SendHttpRequest()
Generic helper to send an HTTP request.
Parameters
| Name | Description | Default |
|---|---|---|
httpMethod |
||
url |
||
headers |
||
body |
||
bodyType |
Returns
Divooka.DSL.HTTPRequest.Main.WebAPITester.SendGET()
Sends an HTTP GET request to the specified URL.
Parameters
| Name | Description | Default |
|---|---|---|
url |
The URL to which the GET request is sent. | |
headers |
Optional headers to include in the request. |
Returns
The response content as a byte array.
Divooka.DSL.HTTPRequest.Main.WebAPITester.SendHEAD()
Sends an HTTP HEAD request to the specified URL.
Parameters
| Name | Description | Default |
|---|---|---|
url |
The URL to which the HEAD request is sent. | |
headers |
Optional headers to include in the request. |
Returns
The response content as a byte array.
Divooka.DSL.HTTPRequest.Main.WebAPITester.SendPOST()
Sends an HTTP POST request to the specified URL with headers, body, and content type.
Parameters
| Name | Description | Default |
|---|---|---|
url |
The URL to which the POST request is sent. | |
headers |
Optional headers to include in the request. | |
body |
The request body as a string. | |
bodyType |
The content type of the request body. |
Returns
The response content as a byte array.
Divooka.DSL.HTTPRequest.Main.WebAPITester.SendPUT()
Sends an HTTP PUT request to the specified URL with headers, body, and content type.
Parameters
| Name | Description | Default |
|---|---|---|
url |
The URL to which the PUT request is sent. | |
headers |
Optional headers to include in the request. | |
body |
The request body as a string. | |
bodyType |
The content type of the request body. |
Returns
The response content as a byte array.
Divooka.DSL.HTTPRequest.Main.WebAPITester.SendDELETE()
Sends an HTTP DELETE request to the specified URL.
Parameters
| Name | Description | Default |
|---|---|---|
url |
The URL to which the DELETE request is sent. | |
headers |
Optional headers to include in the request. |
Returns
The response content as a byte array.
Divooka.DSL.HTTPRequest.Main.WebAPITester.SendCONNECT()
Sends an HTTP CONNECT request to the specified URL with headers, body, and content type.
Parameters
| Name | Description | Default |
|---|---|---|
url |
The URL to which the CONNECT request is sent. | |
headers |
Headers to include in the request. | |
body |
The request body as a string. | |
bodyType |
The content type of the request body. |
Returns
The response content as a byte array.
Divooka.DSL.HTTPRequest.Main.WebAPITester.SendOPTIONS()
Sends an HTTP OPTIONS request to the specified URL.
Parameters
| Name | Description | Default |
|---|---|---|
url |
The URL to which the OPTIONS request is sent. | |
headers |
Optional headers to include in the request. |
Returns
The response content as a byte array.
Divooka.DSL.HTTPRequest.Main.WebAPITester.SendTRACE()
Sends an HTTP TRACE request to the specified URL.
Parameters
| Name | Description | Default |
|---|---|---|
url |
The URL to which the TRACE request is sent. | |
headers |
Optional headers to include in the request. |
Returns
The response content as a byte array.
Divooka.DSL.HTTPRequest.Main.WebAPITester.SendPATCH()
Sends an HTTP PATCH request to the specified URL with headers, body, and content type.
Parameters
| Name | Description | Default |
|---|---|---|
url |
The URL to which the PATCH request is sent. | |
headers |
Headers to include in the request. | |
body |
The request body as a string. | |
bodyType |
The content type of the request body. |
Returns
The response content as a byte array.
Divooka.DSL.HTTPRequest.JSONPreview
Preview data as JSON string, with formatting.