Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class Web

  1. Object
  2. Web

Outbound HTTP and HTTPS for server-side binaries. Backed by libcurl, so TLS verification, redirects, chunked decoding and the system certificate store all come from a library that is maintained for the purpose.

Distinct from Http, which is a raw-socket plaintext client for the host runtime’s loopback control protocol. Use this one for anything real.

Certificate store. A dynamically linked build finds the system CA bundle. A fully static build has whatever the image provides, which for a scratch container is nothing - and TLS then fails with “unable to get local issuer certificate”. Ship a ca-certificates.crt and point curl at it with the CURL_CA_BUNDLE or SSL_CERT_FILE environment variable; both are read by libcurl itself, so no code here has to know about it.

Nested types

class Web.ResultAn outbound response: status, body, and libcurl’s message when it failed.

Methods

public static Web.Result get(String url) throws IOException
public static Web.Result getJson(String url, String bearerToken) throws IOException
public static Web.Result postJson(String url, String json, String bearerToken) throws IOException
public static Web.Result request(String method, String url, List headers, byte[] body) throws IOException
  • headers: a list of “Name: value” strings, or null

Inherited methods

Method details

get

public static Web.Result get(String url) throws IOException

getJson

public static Web.Result getJson(String url, String bearerToken) throws IOException

postJson

public static Web.Result postJson(String url, String json, String bearerToken) throws IOException

request

public static Web.Result request(String method, String url, List headers, byte[] body) throws IOException
  • headers: a list of “Name: value” strings, or null