java.lang.Object
com.inductiveautomation.ignition.common.script.builtin.http.JythonHttpClient

public class JythonHttpClient extends Object
A modern, non-blocking HTTP client for use in scripting (system.net.httpClient).

Wraps the Java 11+ HttpClient, optimized for use from Jython.

  • Method Details

    • parseCharset

      public static Optional<Charset> parseCharset(String contentType) throws org.python.core.PyIgnoreMethodTag
      Throws:
      org.python.core.PyIgnoreMethodTag
    • head

      public Response head(org.python.core.PyObject[] pyArgs, String[] keywords) throws IOException
      Throws:
      IOException
    • headAsync

      public Promise<Response> headAsync(org.python.core.PyObject[] pyArgs, String[] keywords)
    • get

      public Response get(org.python.core.PyObject[] pyArgs, String[] keywords) throws IOException
      Performs a synchronous HTTP GET request.

      Example:

       client = system.net.httpClient()
       response = client.get("https://httpbin.org/get", params={"a": 1})
       if response.good:
           print response.json
       
      Parameters:
      pyArgs - The keyword arguments: 'url', 'params', 'headers', etc.
      keywords - The keyword names.
      Returns:
      A Response object.
      Throws:
      IOException - If an I/O error occurs.
    • getAsync

      public Promise<Response> getAsync(org.python.core.PyObject[] pyArgs, String[] keywords)
      Performs an asynchronous HTTP GET request.
      Parameters:
      pyArgs - The keyword arguments: 'url', 'params', 'headers', etc.
      keywords - The keyword names.
      Returns:
      A Promise that will resolve to a Response.
    • post

      public Response post(org.python.core.PyObject[] pyArgs, String[] keywords) throws IOException
      Performs a synchronous HTTP POST request.
      Parameters:
      pyArgs - The keyword arguments: 'url', 'data', 'headers', etc.
      keywords - The keyword names.
      Returns:
      A Response object.
      Throws:
      IOException - If an I/O error occurs.
    • postAsync

      public Promise<Response> postAsync(org.python.core.PyObject[] pyArgs, String[] keywords)
    • put

      public Response put(org.python.core.PyObject[] pyArgs, String[] keywords) throws IOException
      Throws:
      IOException
    • putAsync

      public Promise<Response> putAsync(org.python.core.PyObject[] pyArgs, String[] keywords)
    • patch

      public Response patch(org.python.core.PyObject[] pyArgs, String[] keywords) throws IOException
      Throws:
      IOException
    • patchAsync

      public Promise<Response> patchAsync(org.python.core.PyObject[] pyArgs, String[] keywords)
    • delete

      public Response delete(org.python.core.PyObject[] pyArgs, String[] keywords) throws IOException
      Throws:
      IOException
    • deleteAsync

      public Promise<Response> deleteAsync(org.python.core.PyObject[] pyArgs, String[] keywords)
    • trace

      public Response trace(org.python.core.PyObject[] pyArgs, String[] keywords) throws IOException
      Throws:
      IOException
    • traceAsync

      public Promise<Response> traceAsync(org.python.core.PyObject[] pyArgs, String[] keywords)
    • options

      public Response options(org.python.core.PyObject[] pyArgs, String[] keywords) throws IOException
      Throws:
      IOException
    • optionsAsync

      public Promise<Response> optionsAsync(org.python.core.PyObject[] pyArgs, String[] keywords)
    • request

      public Response request(org.python.core.PyObject[] pyArgs, String[] keywords) throws IOException
      Throws:
      IOException
    • requestAsync

      public Promise<Response> requestAsync(org.python.core.PyObject[] pyArgs, String[] keywords)
    • __call__

      public JythonHttpClient __call__(org.python.core.PyObject[] pyArgs, String[] keywords) throws Exception
      Throws:
      Exception
    • getCookieManager

      public CookieManager getCookieManager()
    • getGson

      public com.inductiveautomation.ignition.common.gson.Gson getGson()
    • setGson

      public void setGson(com.inductiveautomation.ignition.common.gson.Gson gson)
    • getConnectTimeout

      public long getConnectTimeout()
    • getRedirectPolicy

      public String getRedirectPolicy()
    • getVersion

      public String getVersion()
    • getJavaClient

      public HttpClient getJavaClient()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • buildHttpClient

      public static JythonHttpClient buildHttpClient(org.python.core.PyObject[] pyArgs, String[] keywords, PromiseExecutor executor) throws Exception, org.python.core.PyIgnoreMethodTag
      Throws:
      Exception
      org.python.core.PyIgnoreMethodTag