HttpsClient
HTTPS client
html := HttpsClient->QuickGet(Web.HTTP.Url->New("https://www.nasa.gov")->ToString();
if(html <> Nil) {
html->PrintLine();
};Operations
- New
- AddHeader
- Delete
- EnableCookies
- Get
- GetCookie
- GetCookies
- GetIssuer
- GetRequestHeaders
- GetResponseHeaders
- GetSubject
- HasCookie
- Patch
- Post
- Put
- QuickDelete
- QuickGet
- QuickPatch
- QuickPost
- QuickPut
- RemoveHeader
- SetCookie
- SetMaxRedirects
- SetRetry
- StreamPost
AddHeader #
Adds a HTTPS request header
method : public : AddHeader(name:String, value:String) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| name | String | header name |
| value | String | header value |
Example
client := Web.HTTP.HttpsClient->New();
client->AddHeader("Authorization", "Bearer token123");
client->AddHeader("Accept", "application/json");
response := client->Get(Web.HTTP.Url->New("https://api.example.com/users"));
response->GetCode()->PrintLine();Delete #
Performs a HTTPS DELETE
method : public : Delete(url:Web.HTTP.Url, content_type:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| content_type | String | content type |
Return
| Type | Description |
|---|---|
| Response | string read |
EnableCookies #
Sets cookie support
method : public : EnableCookies(cookies_enabled:Bool) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| cookies_enabled | Bool | true if cookies are enabled, false otherwise |
Example
client := Web.HTTP.HttpsClient->New();
client->EnableCookies(true);
client->Get(Web.HTTP.Url->New("https://example.com/login")); # server sets cookie
client->Get(Web.HTTP.Url->New("https://example.com/profile")); # cookie sent automaticallyGet #
Performs a HTTPS GET
method : public : Get(url:Web.HTTP.Url) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
Return
| Type | Description |
|---|---|
| Response | string read |
Get #
Performs a HTTPS GET
method : public : Get(url:Web.HTTP.Url, content_type:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| content_type | String | content type |
Return
| Type | Description |
|---|---|
| Response | string read |
Get #
Performs a HTTPS GET
method : public : Get(url:Web.HTTP.Url, content_type:String, ) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| content_type | String | content type |
Return
| Type | Description |
|---|---|
| Response | string read |
GetCookie #
Get a cookie
method : public : GetCookie(name:String) ~ CookieParameters
| Name | Type | Description |
|---|---|---|
| name | String | cookie name |
Return
| Type | Description |
|---|---|
| Cookie | found cookie, Nil otherwise |
GetCookies #
Gets the cookies
method : public : GetCookies() ~ Vector<Cookie>Return
| Type | Description |
|---|---|
| Vector<Cookie> | vector of cookies |
GetIssuer #
Gets the socket's X.509 certificate issuer name
method : public : GetIssuer() ~ StringReturn
| Type | Description |
|---|---|
| String | certificate issuer name |
Example
client := Web.HTTP.HttpsClient->New();
client->Get(Web.HTTP.Url->New("https://example.com/"));
client->GetIssuer()->PrintLine(); # e.g. "Let's Encrypt Authority X3"GetRequestHeaders #
Gets the HTTPS request headers
method : public : GetRequestHeaders() ~ Hash<String,String>Return
| Type | Description |
|---|---|
| Hash<String,String> | HTTPS request headers |
GetResponseHeaders #
Gets the HTTPS response headers
method : public : GetResponseHeaders() ~ Hash<String,String>Return
| Type | Description |
|---|---|
| Hash<String,String> | HTTPS response headers |
GetSubject #
Gets the socket's X.509 certificate subject name
method : public : GetSubject() ~ StringReturn
| Type | Description |
|---|---|
| String | certificate subject name |
Example
client := Web.HTTP.HttpsClient->New();
client->Get(Web.HTTP.Url->New("https://example.com/"));
client->GetSubject()->PrintLine(); # e.g. "CN=example.com"HasCookie #
Checks for a cookie
method : public : HasCookie(name:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| name | String | cookie name |
Return
| Type | Description |
|---|---|
| Bool | true if found cookie, false otherwise |
New # constructor
Default constructor
New(cookies_enabled:Bool)Parameters
| Name | Type | Description |
|---|---|---|
| cookies_enabled | Bool | true if cookies are enabled, false otherwise |
Example
client := Web.HTTP.HttpsClient->New();
client->AddHeader("Authorization", "Bearer mytoken");
response := client->Get(Web.HTTP.Url->New("https://api.example.com/data"));
if(response <> Nil) {
response->GetCode()->PrintLine(); # 200
};Patch #
Performs a HTTPS PATCH
method : public : Patch(url:Web.HTTP.Url, data:Byte[], content_type:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to patch |
| content_type | String | content type |
Return
| Type | Description |
|---|---|
| Response | string read |
Patch #
Performs a HTTPS PATCH
method : public : Patch(url:Web.HTTP.Url, data:Byte[], content_type:String, pem:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to patch |
| content_type | String | content type |
| pem | String | the Privacy Enhanced Mail file |
Return
| Type | Description |
|---|---|
| Response | string read |
Patch #
Performs a HTTPS PATCH
method : public : Patch(url:Web.HTTP.Url, data:Byte[]) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to patch |
Return
| Type | Description |
|---|---|
| Response | string read |
Post #
Performs a HTTPS POST
method : public : Post(url:Web.HTTP.Url, data:Byte[], content_type:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to oper |
| content_type | String | content type |
Return
| Type | Description |
|---|---|
| Response | string read |
Post #
Performs a HTTPS POST
method : public : Post(url:Web.HTTP.Url, data:Byte[], content_type:String, pem:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to oper |
| content_type | String | content type |
| pem | String | the Privacy Enhanced Mail file |
Return
| Type | Description |
|---|---|
| Response | string read |
Post #
Performs a HTTPS POST
method : public : Post(url:Web.HTTP.Url, data:Byte[]) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to oper |
Return
| Type | Description |
|---|---|
| Response | string read |
Put #
Performs a HTTPS PUT
method : public : Put(url:Web.HTTP.Url, data:Byte[], content_type:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to oper |
| content_type | String | content type |
Return
| Type | Description |
|---|---|
| Response | string read |
Put #
Performs a HTTPS PUT
method : public : Put(url:Web.HTTP.Url, data:Byte[], content_type:String, pem:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to oper |
| content_type | String | content type |
| pem | String | the Privacy Enhanced Mail file |
Return
| Type | Description |
|---|---|
| Response | string read |
Put #
Performs a HTTPS PUT
method : public : Put(url:Web.HTTP.Url, data:Byte[]) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to oper |
Return
| Type | Description |
|---|---|
| Response | string read |
QuickDelete # function
Performs a HTTPS DELETE and returns results as a String
function : QuickDelete(url:Web.HTTP.Url) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
Return
| Type | Description |
|---|---|
| Response | output buffer |
Example
url := Web.HTTP.Url->New("https://api.example.com/items/42");
response := Web.HTTP.HttpsClient->QuickDelete(url);
response->GetCode()->PrintLine(); # 204QuickDelete # function
Performs a HTTPS DELETE and returns results as a String
function : QuickDelete(url:Web.HTTP.Url, headers:Map<String,String>) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| headers | Map<String,String> | key/value headers |
Return
| Type | Description |
|---|---|
| Response | output buffer |
QuickDelete # function
Performs a HTTPS DELETE and returns results as a String
function : QuickDelete(url:Web.HTTP.Url, content_type:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| content_type | String | content type |
Return
| Type | Description |
|---|---|
| Response | output buffer |
QuickDelete # function
Performs a HTTPS DELETE and returns results as a String
function : QuickDelete(url:Web.HTTP.Url, content_type:String, headers:Map<String,String>) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| content_type | String | content type |
| headers | Map<String,String> | key/value headers |
Return
| Type | Description |
|---|---|
| Response | output buffer |
QuickDelete # function
Performs a HTTPS DELETE and returns results as a String
function : QuickDelete(url:Web.HTTP.Url, content_type:String, headers:Map<String,String>, pem:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| content_type | String | content type |
| headers | Map<String,String> | key/value headers |
| pem | String | the Privacy Enhanced Mail file |
Return
| Type | Description |
|---|---|
| Response | output buffer |
QuickGet # function
Performs a HTTPS GET and returns results as a String
function : QuickGet(url:Web.HTTP.Url) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
Return
| Type | Description |
|---|---|
| Response | output buffer |
Example
url := Web.HTTP.Url->New("https://httpbin.org/get");
response := Web.HTTP.HttpsClient->QuickGet(url);
if(response <> Nil) {
response->GetCode()->PrintLine(); # 200
String->New(response->GetContent())->PrintLine(); # JSON body
};QuickGet # function
Performs a HTTPS GET and returns results as a String
function : QuickGet(url:Web.HTTP.Url, headers:Map<String,String>) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| headers | Map<String,String> | key/value headers |
Return
| Type | Description |
|---|---|
| Response | output buffer |
QuickGet # function
Performs a HTTPS GET and returns results as a String
function : QuickGet(url:Web.HTTP.Url, content_type:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| content_type | String | content type |
Return
| Type | Description |
|---|---|
| Response | output buffer |
QuickGet # function
Performs a HTTPS GET and returns results as a String
function : QuickGet(url:Web.HTTP.Url, content_type:String, headers:Map<String,String>) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| content_type | String | content type |
| headers | Map<String,String> | key/value headers |
Return
| Type | Description |
|---|---|
| Response | output buffer |
QuickGet # function
Performs a HTTPS GET and returns results as a String
function : QuickGet(url:Web.HTTP.Url, content_type:String, headers:Map<String,String>, pem:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| content_type | String | content type |
| headers | Map<String,String> | key/value headers |
| pem | String | the Privacy Enhanced Mail file |
Return
| Type | Description |
|---|---|
| Response | output buffer |
QuickPatch # function
Performs a HTTPS PATCH
function : QuickPatch(url:Web.HTTP.Url, data:Byte[]) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to patch |
Return
| Type | Description |
|---|---|
| Response | read strings |
Example
url := Web.HTTP.Url->New("https://api.example.com/items/1");
body := "{\"status\":\"active\"}"->ToByteArray();
response := Web.HTTP.HttpsClient->QuickPatch(url, body, "application/json");
response->GetCode()->PrintLine(); # 200QuickPatch # function
Performs a HTTPS PATCH
function : QuickPatch(url:Web.HTTP.Url, data:Byte[], content_type:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to patch |
| content_type | String | content type |
Return
| Type | Description |
|---|---|
| Response | read strings |
QuickPatch # function
Performs a HTTPS PATCH
function : QuickPatch(url:Web.HTTP.Url, data:Byte[], content_type:String, headers:Map<String,String>) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to patch |
| content_type | String | content type |
| headers | Map<String,String> | key/value headers |
Return
| Type | Description |
|---|---|
| Response | read strings |
QuickPost # function
Performs a HTTPS POST
function : QuickPost(url:Web.HTTP.Url, data:Byte[]) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to oper |
Return
| Type | Description |
|---|---|
| Response | read strings |
Example
url := Web.HTTP.Url->New("https://httpbin.org/post");
body := "field=value"->ToByteArray();
response := Web.HTTP.HttpsClient->QuickPost(url, body);
response->GetCode()->PrintLine(); # 200QuickPost # function
Performs a HTTPS POST
function : QuickPost(url:Web.HTTP.Url, data:Byte[], content_type:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to oper |
| content_type | String | content type |
Return
| Type | Description |
|---|---|
| Response | read strings |
QuickPost # function
Performs a HTTPS POST
function : QuickPost(url:Web.HTTP.Url, data:Byte[], content_type:String, headers:Map<String,String>) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to oper |
| content_type | String | content type |
| headers | Map<String,String> | key/value headers |
Return
| Type | Description |
|---|---|
| Response | read strings |
QuickPut # function
Performs a HTTP POST
function : QuickPut(url:Web.HTTP.Url, data:Byte[]) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to oper |
Return
| Type | Description |
|---|---|
| Response | read strings |
QuickPut # function
Performs a HTTPS POST
function : QuickPut(url:Web.HTTP.Url, data:Byte[], content_type:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to oper |
| content_type | String | content type |
Return
| Type | Description |
|---|---|
| Response | read strings |
QuickPut # function
Performs a HTTP POST
function : QuickPut(url:Web.HTTP.Url, data:Byte[], content_type:String, headers:Map<String,String>) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | data to oper |
| content_type | String | content type |
| headers | Map<String,String> | key/value headers |
Return
| Type | Description |
|---|---|
| Response | read strings |
RemoveHeader #
Removes a HTTPS request header
method : public : RemoveHeader(name:String) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| name | String | header name |
Example
client := Web.HTTP.HttpsClient->New();
client->RemoveHeader("Cache-Control"); # strip default cache header
response := client->Get(Web.HTTP.Url->New("https://api.example.com/data"));
response->GetCode()->PrintLine();SetCookie #
Sets a cookie
method : public : SetCookie(cookie:Cookie) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| cookie | Cookie | cookie |
SetMaxRedirects #
Sets the maximum number of redirects to follow (default 10)
method : public : SetMaxRedirects(max:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| max | Int | maximum redirects |
Example
client := Web.HTTP.HttpsClient->New();
client->SetMaxRedirects(5);
response := client->Get(Web.HTTP.Url->New("https://httpbin.org/redirect/3"));
response->GetCode()->PrintLine(); # 200SetRetry #
Sets retry behavior for transient errors (429, 503)
method : public : SetRetry(max_retries:Int, delay_ms:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| max_retries | Int | maximum retry attempts (default 3, 0 to disable) |
| delay_ms | Int | initial delay between retries in milliseconds (default 1000, doubles each retry) |
Example
client := Web.HTTP.HttpsClient->New();
client->SetRetry(5, 500); # retry up to 5 times, starting at 500ms
response := client->Get(Web.HTTP.Url->New("https://api.example.com/data"));
response->GetCode()->PrintLine();StreamPost #
Performs an HTTPS POST and returns an SSE stream for reading events. Used for streaming responses from LLM APIs.
method : public : StreamPost(url:Web.HTTP.Url, data:Byte[], content_type:String) ~ SSEStreamParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | request body |
| content_type | String | content type |
Return
| Type | Description |
|---|---|
| SSEStream | SSE stream, or Nil on error |
Example
client := Web.HTTP.HttpsClient->New();
client->AddHeader("Authorization", "Bearer mykey");
url := Web.HTTP.Url->New("https://api.openai.com/v1/chat/completions");
body := "{\"model\":\"gpt-4o\",\"stream\":true,\"messages\":[]}"->ToByteArray();
stream := client->StreamPost(url, body, "application/json");
if(stream <> Nil) {
while(stream->HasNext()) {
stream->Next()->GetData()->PrintLine();
};
stream->Close();
};StreamPost #
Performs an HTTPS POST and returns an SSE stream for reading events.
method : public : StreamPost(url:Web.HTTP.Url, data:Byte[], content_type:String, pem:String) ~ SSEStreamParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL |
| data | Byte | request body |
| content_type | String | content type |
| pem | String | PEM certificate |
Return
| Type | Description |
|---|---|
| SSEStream | SSE stream, or Nil on error |