Module: nupp.io.http
An optional asynchronous HTTP client whose sockets and TLS run in the native Reqwest/Tokio provider. Calls suspend through nupp.suspension: a CLI blocks on the provider's condvar, while a scheduler or SDL host only drives the nonblocking source.
Response bodies and generic request readers are progressive and bounded. A response status is an answer (including 4xx and 5xx); transport and body failures are returned as reasons.
Module contents
Constructors
| Constructor | Description |
|---|---|
newClient | — |
Types
| Type | Kind | Description |
|---|---|---|
Body | record | — |
Client | record | — |
FileBody | record | — |
Options | record | — |
ReaderBody | record | — |
Request | record | — |
RequestBody | type | — |
Response | record | — |
Version | type | — |
Functions
| Function | Kind | Description |
|---|---|---|
Client:close | method | — |
Client:pending | method | — |
Client:send | method | — |
file | function | — |
reader | function | — |
Constructors#
http.newClientconstructor#
Arguments
| Name | Type | Description |
|---|---|---|
options | http.Options? |
Returns
| Type | Description |
|---|---|
http.Client? | |
string? |
Types#
Bodyrecord#
record http.Body is nupp.Reader
_client: any
_transfer: any
_closed: boolean
_reading: boolean
function _next(self, count: integer, destination: nupp.Buffer?, offset: integer): (any?, string?)
end
function read(self, count: integer): (string?, string?)
end
function readInto(self, destination: nupp.Buffer, offset: integer?, count: integer?): (integer?, string?)
end
function transferTo(self, destination: nupp.Writer): (integer?, string?)
end
function close(self): (boolean, string?)
end
function release(self): nil
end
endMethods
read
read: function read(self, count: integer): string?, string?Arguments
| Name | Type | Description |
|---|---|---|
self | any | |
count | integer |
Returns
| Type | Description |
|---|---|
string? | |
string? |
readInto
readInto: function readInto(self, destination: nupp.Buffer, offset: integer?, count: integer?): integer?, string?Arguments
| Name | Type | Description |
|---|---|---|
self | any | |
destination | nupp.Buffer | |
offset | integer? | |
count | integer? |
Returns
| Type | Description |
|---|---|
integer? | |
string? |
transferTo
Arguments
| Name | Type | Description |
|---|---|---|
self | any | |
destination | nupp.Writer |
Returns
| Type | Description |
|---|---|
integer? | |
string? |
close
close: function close(self): boolean, string?Arguments
| Name | Type | Description |
|---|---|---|
self | any |
Returns
| Type | Description |
|---|---|
boolean | |
string? |
release
release: function release(self): nilArguments
| Name | Type | Description |
|---|---|---|
self | any |
Returns
| Type | Description |
|---|---|
nil |
Clientrecord#
FileBodyrecord#
record http.FileBody
path: string | nupp.Path
contentType: string?
endFields
| Name | Type | Description |
|---|---|---|
path | string | nupp.Path | |
contentType | string? |
Optionsrecord#
record http.Options
userAgent: string?
headers: {
string: string
}?
timeoutMs: integer?
connectTimeoutMs: integer?
stallTimeoutMs: integer?
maxRedirects: integer?
maxPendingRequests: integer?
maxConnections: integer?
maxConnectionsPerHost: integer?
maxBytes: integer?
compressed: boolean?
insecureHosts: {string}?
proxy: string?
noProxy: string?
proxyCredentials: string?
endFields
| Name | Type | Description |
|---|---|---|
userAgent | string? | |
headers | {string: string}? | |
timeoutMs | integer? | |
connectTimeoutMs | integer? | |
stallTimeoutMs | integer? | |
maxRedirects | integer? | |
maxPendingRequests | integer? | |
maxConnections | integer? | |
maxConnectionsPerHost | integer? | |
maxBytes | integer? | |
compressed | boolean? | |
insecureHosts | {string}? | |
proxy | string? | |
noProxy | string? | |
proxyCredentials | string? |
ReaderBodyrecord#
record http.ReaderBody
reader: nupp.Reader
length: integer?
contentType: string?
endFields
| Name | Type | Description |
|---|---|---|
reader | nupp.Reader | |
length | integer? | |
contentType | string? |
Requestrecord#
record http.Request
url: nupp.URI
method: string?
headers: {
string: string
}?
body: http.RequestBody?
timeoutMs: integer?
stallTimeoutMs: integer?
maxBytes: integer?
endFields
| Name | Type | Description |
|---|---|---|
url | nupp.URI | |
method | string? | |
headers | {string: string}? | |
body | http.RequestBody? | |
timeoutMs | integer? | |
stallTimeoutMs | integer? | |
maxBytes | integer? |
RequestBodytype#
type http.RequestBody = string | nupp.ByteView | nupp.Buffer | http.ReaderBody | http.FileBodyResponserecord#
record http.Response
status: integer
version: http.Version
url: nupp.URI
body: owned<http.Body>
_packed: string
_values: {[string]: {string}}?
_headers: {
string: string
}?
_closed: boolean
function _decode(self): nil
end
function ok(self): boolean
end
function header(self, name: string): string?
end
function getAll(self, name: string): {string}
end
function headers(self): {
string: string
}
end
function close(self): (boolean, string?)
end
endMethods
ok
ok: function ok(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self | any |
Returns
| Type | Description |
|---|---|
boolean |
header
header: function header(self, name: string): string?Arguments
| Name | Type | Description |
|---|---|---|
self | any | |
name | string |
Returns
| Type | Description |
|---|---|
string? |
getAll
getAll: function getAll(self, name: string): {string}Arguments
| Name | Type | Description |
|---|---|---|
self | any | |
name | string |
Returns
| Type | Description |
|---|---|
{string} |
headers
headers: function headers(self): {string: string}Arguments
| Name | Type | Description |
|---|---|---|
self | any |
Returns
| Type | Description |
|---|---|
{string: string} |
close
close: function close(self): boolean, string?Arguments
| Name | Type | Description |
|---|---|---|
self | any |
Returns
| Type | Description |
|---|---|
boolean | |
string? |
Fields
| Name | Type | Description |
|---|---|---|
status | integer | |
version | http.Version | |
url | nupp.URI | |
body | owned<http.Body> |
Versiontype#
type http.Version = "1.0" | "1.1" | "2"Functions#
http.Client:closemethod#
function http.Client:close(): boolean, string?Returns
| Type | Description |
|---|---|
boolean | |
string? |
http.Client:pendingmethod#
function http.Client:pending(): integerReturns
| Type | Description |
|---|---|
integer |
http.Client:sendmethod#
Arguments
| Name | Type | Description |
|---|---|---|
request | http.Request |
Returns
| Type | Description |
|---|---|
http.Response? | |
string? |
http.filefunction#
Arguments
| Name | Type | Description |
|---|---|---|
path | string | nupp.Path | |
contentType | string? |
Returns
| Type | Description |
|---|---|
http.FileBody |
http.readerfunction#
function http.reader(reader: nupp.Reader, length: integer?, contentType: string?): http.ReaderBodyArguments
| Name | Type | Description |
|---|---|---|
reader | nupp.Reader | |
length | integer? | |
contentType | string? |
Returns
| Type | Description |
|---|---|
http.ReaderBody |