Interface HTTP

The HTTP module provides a simple interface to make HTTP requests. It also provides a XML-RPC client and a download function which can be used to download files to user's disk.

Example

// print the source of IINA's homepage
const res = await http.get("https://iina.io");
console.log(res.text);

Available In Entry

Main and Global

Hierarchy

  • HTTP

Methods

  • Send an HTTP GET request.

    Example

    http.get("https://iina.io", { headers: { "User-Agent": "IINA" } });
    

    Type Parameters

    • ReqData = Record<string, any>

    • ResData = any

    Parameters

    • url: string
    • options: HTTPRequestOption<ReqData>

      The options for the request, including headers and parameters.

    Returns Promise<HTTPResponse<ResData>>

  • Send an HTTP POST request.

    Type Parameters

    • ReqData = Record<string, any>

    • ResData = any

    Parameters

    • url: string
    • options: HTTPRequestOption<ReqData>

      The options for the request, including headers and parameters.

    Returns Promise<HTTPResponse<ResData>>

  • Send an HTTP PUT request.

    Type Parameters

    • ReqData = Record<string, any>

    • ResData = any

    Parameters

    • url: string
    • options: HTTPRequestOption<ReqData>

      The options for the request, including headers and parameters.

    Returns Promise<HTTPResponse<ResData>>

  • Send an HTTP PATCH request.

    Type Parameters

    • ReqData = Record<string, any>

    • ResData = any

    Parameters

    • url: string
    • options: HTTPRequestOption<ReqData>

      The options for the request, including headers and parameters.

    Returns Promise<HTTPResponse<ResData>>

  • Send an HTTP DELETE request.

    Type Parameters

    • ReqData = Record<string, any>

    • ResData = any

    Parameters

    • url: string
    • options: HTTPRequestOption<ReqData>

      The options for the request, including headers and parameters.

    Returns Promise<HTTPResponse<ResData>>

  • Download a file to user's local file system.

    Example

    // download a file to the plugin's data folder
    await http.download("https://example.com/file.zip", "@data/file.zip");

    Parameters

    • url: string

      The URL of the file to download.

    • dest: string

      The destination path, including the file name. The path follows IINA plugin API's file path convention; see the file module for more information. The file-system permission is required in Info.json if the destination is outside the plugin's sandbox.

    • Optional options: HTTPRequestOption<Record<string, any>> & {
          method: string;
      }

      The options for the request, including headers and parameters. Additionally, you can specify the HTTP method to use.

    Returns Promise<undefined>

Generated using TypeDoc