Stof Docs
Star on GitHubStof WebsiteDiscordContact Us
  • 🚀Welcome
  • â„šī¸Resources & Information
  • Book
    • Data Interface
    • Introduction & Design
    • Host Environments
      • Rust
      • TypeScript
        • Extend Stof
        • Import Statement
    • Data Interchange
      • JSON to Stof
      • Importing and Parsing Data
      • Exporting Data
      • REST and Restructure
    • Configuration Files
    • Schemas
      • Renaming Fields
      • Removing Fields
      • Validation & Transformation
        • Example Access
      • Nested Schemas
    • Orchestration
  • Common Concepts
    • Objects
    • Primitive Types
    • Functions
    • Fields
    • Object Types
    • Imports
    • Error Handling
    • Units
    • Casting/Conversions
  • Reference
    • CLI
      • 🏃Run
      • đŸ§ĒTest
      • 📚CLI Libraries
        • Filesystem Library
        • Time Library
        • HTTP Library
    • Stof Language
    • Libraries
      • Standard Library
      • Array/Vector Library
      • Number Library
      • String Library
      • Object Library
      • Function Library
      • Set Library
      • Map Library
      • Data Library
      • Tuple Library
      • Blob Library
      • Boolean Library
    • đŸĒ§Formats
Powered by GitBook
On this page
  • HTTP.get(url: str, headers?: map, body?: str | blob, timeout?: float | units, response?: obj): (content_type: str, response_headers: map, body: blob)
  • HTTP.post(url: str, headers?: map, body?: str | blob, timeout?: float | units, response?: obj): (content_type: str, response_headers: map, body: blob)
  • HTTP.put(url: str, headers?: map, body?: str | blob, timeout?: float | units, response?: obj): (content_type: str, response_headers: map, body: blob)
  • HTTP.delete(url: str, headers?: map, body?: str | blob, timeout?: float | units, response?: obj): (content_type: str, response_headers: map, body: blob)
  • HTTP.patch(url: str, headers?: map, body?: str | blob, timeout?: float | units, response?: obj): (content_type: str, response_headers: map, body: blob)
  • HTTP.head(url: str, headers?: map, body?: str | blob, timeout?: float | units, response?: obj): (content_type: str, response_headers: map, body: blob)

Was this helpful?

  1. Reference
  2. CLI
  3. CLI Libraries

HTTP Library

CLI HTTP library ("HTTP").

PreviousTime LibraryNextStof Language

Last updated 3 months ago

Was this helpful?

The that the CLI uses is separate from Stof. It is required that you to add this library when invoking the CLI. Otherwise, the CLI will not add it and you will not have network access while running your Stof document.

An example using this library can be found on the page REST and Restructure.

HTTP.get(url: str, headers?: map, body?: str | blob, timeout?: float | units, response?: obj): (content_type: str, response_headers: map, body: blob)

HTTP GET request.

The URL argument is required, but everything else is optional. You may skip providing arguments that you do not need. For example "HTTP.get(url, timeout)" would be acceptable. However, if you need all arguments, they are required to be in this order.

The request header map must have string keys and string values (if provided).

Timeout defaults to 5 seconds, but you may use as needed.

If a response object is provided, Stof will use the it has access to and the Content-Type header in the response headers to parse the response body into the provided object.

If adding a request body, it is helpful to use the stringify and blobify functions, creating a body in the format of your choice.

The return type is a tuple, giving you easy access to the response content type, headers, and body. You can then use these to the body into the document, or further orchestrate additional requests.

HTTP.post(url: str, headers?: map, body?: str | blob, timeout?: float | units, response?: obj): (content_type: str, response_headers: map, body: blob)

HTTP POST request. Identical in implementation to , but uses the POST request method.

HTTP.put(url: str, headers?: map, body?: str | blob, timeout?: float | units, response?: obj): (content_type: str, response_headers: map, body: blob)

HTTP PUT request. Identical in implementation to , but uses the PUT request method.

HTTP.delete(url: str, headers?: map, body?: str | blob, timeout?: float | units, response?: obj): (content_type: str, response_headers: map, body: blob)

HTTP.patch(url: str, headers?: map, body?: str | blob, timeout?: float | units, response?: obj): (content_type: str, response_headers: map, body: blob)

HTTP.head(url: str, headers?: map, body?: str | blob, timeout?: float | units, response?: obj): (content_type: str, response_headers: map, body: blob)

HTTP DELETE request. Identical in implementation to , but uses the DELETE request method.

HTTP PATCH request. Identical in implementation to , but uses the PATCH request method.

HTTP HEAD request. Identical in implementation to , but uses the HEAD request method.

📚
HTTP library
give the option
Stof time units
formats
Standard Library
parse
GET
GET
GET
GET
GET