Http3Client
HTTP/3 client over QUIC. Maintains a persistent QUIC connection via a native Http3Session.
client := Http3Client->New("cloudflare-quic.com");
resp := client->Get("/");
if(resp <> Nil) {
resp->GetCode()->PrintLine();
};
client->Close();Operations
- New
- AddHeader
- Close
- Delete
- Get
- IsConnected
- Patch
- Post
- Put
- QuickDelete
- QuickGet
- QuickPatch
- QuickPost
- QuickPut
- RemoveHeader
AddHeader #
Adds a custom request header sent with every subsequent request.
method : public : AddHeader(key:String, value:String) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| key | String | header name (lower-case recommended) |
| value | String | header value |
Example
client := Web.HTTP.Http3Client->New("api.example.com");
client->AddHeader("authorization", "Bearer mytoken");
client->AddHeader("accept", "application/json");
resp := client->Get("/v1/items");
resp->GetCode()->PrintLine();
client->Close();Close #
Closes the QUIC connection and releases resources.
method : public : Close() ~ NilExample
client := Web.HTTP.Http3Client->New("api.example.com");
resp := client->Get("/data");
resp->GetCode()->PrintLine();
client->Close(); # release QUIC/ngtcp2 sessionDelete #
Performs an HTTP/3 DELETE request.
method : public : Delete(path:String) ~ ResponseParameters
| Name | Type | Description |
|---|---|---|
| path | String | request path |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
Example
client := Web.HTTP.Http3Client->New("api.example.com");
resp := client->Delete("/records/5");
resp->GetCode()->PrintLine(); # 204
client->Close();Get #
Performs an HTTP/3 GET request.
method : public : Get(path:String) ~ ResponseParameters
| Name | Type | Description |
|---|---|---|
| path | String | request path |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
Example
client := Web.HTTP.Http3Client->New("cloudflare-quic.com");
resp := client->Get("/cdn-cgi/trace");
if(resp <> Nil) {
resp->GetCode()->PrintLine(); # 200
String->New(resp->GetContent())->PrintLine();
};
client->Close();IsConnected #
Returns true if the QUIC connection is established
method : public : IsConnected() ~ BoolExample
client := Web.HTTP.Http3Client->New("cloudflare-quic.com");
if(client->IsConnected()) {
resp := client->Get("/");
resp->GetCode()->PrintLine(); # 200
};
client->Close();New # constructor
Creates an HTTP/3 client connected to the given host.
New(host:String, port:Int)Parameters
| Name | Type | Description |
|---|---|---|
| host | String | hostname (e.g. "api.example.com") |
| port | Int | port number (default 443) |
Patch #
Performs an HTTP/3 PATCH request.
method : public : Patch(path:String, body:Byte[], content_type:String) ~ ResponseParameters
| Name | Type | Description |
|---|---|---|
| path | String | request path |
| body | Byte | request body bytes |
| content_type | String | MIME type of the body |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
Example
client := Web.HTTP.Http3Client->New("api.example.com");
payload := "{\"active\":false}"->ToByteArray();
resp := client->Patch("/users/3", payload, "application/json");
resp->GetCode()->PrintLine(); # 200
client->Close();Post #
Performs an HTTP/3 POST request.
method : public : Post(path:String, body:Byte[], content_type:String) ~ ResponseParameters
| Name | Type | Description |
|---|---|---|
| path | String | request path |
| body | Byte | request body bytes |
| content_type | String | MIME type of the body |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
Example
client := Web.HTTP.Http3Client->New("api.example.com");
payload := "{\"name\":\"test\"}"->ToByteArray();
resp := client->Post("/items", payload, "application/json");
resp->GetCode()->PrintLine(); # 201
client->Close();Put #
Performs an HTTP/3 PUT request.
method : public : Put(path:String, body:Byte[], content_type:String) ~ ResponseParameters
| Name | Type | Description |
|---|---|---|
| path | String | request path |
| body | Byte | request body bytes |
| content_type | String | MIME type of the body |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
Example
client := Web.HTTP.Http3Client->New("api.example.com");
payload := "{\"value\":99}"->ToByteArray();
resp := client->Put("/settings/theme", payload, "application/json");
resp->GetCode()->PrintLine(); # 200
client->Close();QuickDelete # function
Performs an HTTP/3 DELETE from a URL in one call.
function : QuickDelete(url:Web.HTTP.Url) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL to delete |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
Example
url := Web.HTTP.Url->New("https://api.example.com/items/12");
resp := Web.HTTP.Http3Client->QuickDelete(url);
resp->GetCode()->PrintLine(); # 204QuickDelete # function
Performs an HTTP/3 DELETE from a URL with custom headers.
function : QuickDelete(url:Web.HTTP.Url, headers:Map<String,String>) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL to delete |
| headers | Map<String,String> | optional key/value headers |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
QuickGet # function
Performs an HTTP/3 GET from a URL in one call.
function : QuickGet(url:Web.HTTP.Url) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL to fetch |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
Example
url := Web.HTTP.Url->New("https://cloudflare-quic.com/cdn-cgi/trace");
resp := Web.HTTP.Http3Client->QuickGet(url);
if(resp <> Nil) {
resp->GetCode()->PrintLine(); # 200
String->New(resp->GetContent())->PrintLine();
};QuickGet # function
Performs an HTTP/3 GET from a URL with custom headers.
function : QuickGet(url:Web.HTTP.Url, headers:Map<String,String>) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL to fetch |
| headers | Map<String,String> | optional key/value headers |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
QuickPatch # function
Performs an HTTP/3 PATCH from a URL in one call.
function : QuickPatch(url:Web.HTTP.Url, data:Byte[]) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL to patch |
| data | Byte | request body |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
QuickPatch # function
Performs an HTTP/3 PATCH from a URL with a content type.
function : QuickPatch(url:Web.HTTP.Url, data:Byte[], content_type:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL to patch |
| data | Byte | request body |
| content_type | String | MIME type |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
QuickPatch # function
Performs an HTTP/3 PATCH from a URL with content type and headers.
function : QuickPatch(url:Web.HTTP.Url, data:Byte[], content_type:String, headers:Map<String,String>) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL to patch |
| data | Byte | request body |
| content_type | String | MIME type |
| headers | Map<String,String> | optional key/value headers |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
QuickPost # function
Performs an HTTP/3 POST from a URL in one call.
function : QuickPost(url:Web.HTTP.Url, data:Byte[]) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL to post to |
| data | Byte | request body |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
Example
url := Web.HTTP.Url->New("https://api.example.com/submit");
body := "{\"msg\":\"hello\"}"->ToByteArray();
resp := Web.HTTP.Http3Client->QuickPost(url, body, "application/json");
resp->GetCode()->PrintLine(); # 200QuickPost # function
Performs an HTTP/3 POST from a URL with a content type.
function : QuickPost(url:Web.HTTP.Url, data:Byte[], content_type:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL to post to |
| data | Byte | request body |
| content_type | String | MIME type |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
QuickPost # function
Performs an HTTP/3 POST from a URL with content type and headers.
function : QuickPost(url:Web.HTTP.Url, data:Byte[], content_type:String, headers:Map<String,String>) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL to post to |
| data | Byte | request body |
| content_type | String | MIME type |
| headers | Map<String,String> | optional key/value headers |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
QuickPut # function
Performs an HTTP/3 PUT from a URL in one call.
function : QuickPut(url:Web.HTTP.Url, data:Byte[]) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL to put to |
| data | Byte | request body |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
QuickPut # function
Performs an HTTP/3 PUT from a URL with a content type.
function : QuickPut(url:Web.HTTP.Url, data:Byte[], content_type:String) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL to put to |
| data | Byte | request body |
| content_type | String | MIME type |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
QuickPut # function
Performs an HTTP/3 PUT from a URL with content type and headers.
function : QuickPut(url:Web.HTTP.Url, data:Byte[], content_type:String, headers:Map<String,String>) ~ Web.HTTP.ResponseParameters
| Name | Type | Description |
|---|---|---|
| url | Url | URL to put to |
| data | Byte | request body |
| content_type | String | MIME type |
| headers | Map<String,String> | optional key/value headers |
Return
| Type | Description |
|---|---|
| Response | Response or Nil on failure |
RemoveHeader #
Removes a previously added request header.
method : public : RemoveHeader(key:String) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| key | String | header name |
Example
client := Web.HTTP.Http3Client->New("api.example.com");
client->AddHeader("x-debug", "1");
client->RemoveHeader("x-debug");
resp := client->Get("/ping");
client->Close();