Struct

struct HttpStatusCode

public struct HttpStatusCode

Description: Specifies a 3-digit code that indicates the response status of Hypertext Transfer Protocol (HTTP) of the web server.

Status codes are defined in RFC 9110 and in extended specifications RFC2518, RFC 3229, RFC 4918, RFC 5842, RFC 7168, and RFC 8297.

The first digit of all status codes indicates one of the following five types of response:

  • 1xx (information): indicates an interim response for the communication connection status or request progress before the requested operation is completed and the final response is sent.
  • 2xx (success): indicates that the client's request has been successfully received, understood, and accepted.
  • 3xx (redirection): indicates that the user proxy needs to take further actions to complete the request.
  • 4xx (client error): indicates that an error occurs on the client.
  • 5xx (server error): indicates that the server is aware of an error or it cannot fulfill the request.

static const STATUS_ACCEPTED

public static const STATUS_ACCEPTED: UInt16 = 202

Description: The server has accepted the request but has not processed it.

Type: Int64

static const STATUS_ALREADY_REPORTED

public static const STATUS_ALREADY_REPORTED: UInt16 = 208

Description: The message body is an XML message.

Type: Int64

static const STATUS_BAD_GATEWAY

public static const STATUS_BAD_GATEWAY: UInt16 = 502

Description: The server, when attempting to fulfill the request as a gateway or proxy, receives an invalid response from its upstream server.

Type: Int64

static const STATUS_BAD_REQUEST

public static const STATUS_BAD_REQUEST: UInt16 = 400

Description: The request cannot be understood by the server due to incorrect syntax or request parameters.

Type: Int64

static const STATUS_CONFLICT

public static const STATUS_CONFLICT: UInt16 = 409

Description: The request cannot be fulfilled due to a conflict with the current state of the requested resource.

Type: Int64

static const STATUS_CONTINUE

public static const STATUS_CONTINUE: UInt16 = 100

Description: This interim response is issued while request processing continues. It alerts the client to wait for a final response.

Type: Int64

Note:

The client should continue sending the remaining part of the request, or ignore the response if the request has been fulfilled. The server must send a final response to the client after the request is fulfilled.

static const STATUS_CREATED

public static const STATUS_CREATED: UInt16 = 201

Description: The request has been fulfilled and resulted in a new resource being created, and the URI of the resource has been returned with the Location header information.

Type: Int64

static const STATUS_EARLY_HINTS

public static const STATUS_EARLY_HINTS: UInt16 = 103

Description: Preloads CSS and JS files in advance.

Type: Int64

static const STATUS_EXPECTATION_FAILED

public static const STATUS_EXPECTATION_FAILED: UInt16 = 417

Description: The server fails to meet the Expect request header information.

Type: Int64

static const STATUS_FAILED_DEPENDENCY

public static const STATUS_FAILED_DEPENDENCY: UInt16 = 424

Description: The current request fails due to an error in a previous request.

Type: Int64

static const STATUS_FORBIDDEN

public static const STATUS_FORBIDDEN: UInt16 = 403

Description: The server has understood the request but refuses to fulfill it.

Type: Int64

static const STATUS_FOUND

public static const STATUS_FOUND: UInt16 = 302

Description: Assigns a new temporary URI.

Type: Int64

Note:

The requested resource has been assigned a new temporary URI. The client should send subsequent requests to the original URI.

static const STATUS_GATEWAY_TIMEOUT

public static const STATUS_GATEWAY_TIMEOUT: UInt16 = 504

Description: The response from the upstream server (identified by the URI, such as HTTP, FTP, and LDAP) or secondary server (such as DNS) times out.

Type: Int64

static const STATUS_GONE

public static const STATUS_GONE: UInt16 = 410

Description: The requested resource is no longer available on the server and no forwarding address is known.

Type: Int64

static const STATUS_HTTP_VERSION_NOT_SUPPORTED

public static const STATUS_HTTP_VERSION_NOT_SUPPORTED: UInt16 = 505

Description: The server does not support or refuses to support the HTTP version used in the request.

Type: Int64

static const STATUS_IM_USED

public static const STATUS_IM_USED: UInt16 = 226

Description: The server has fulfilled the request for the resource, and the response represents the result of one or more instance operations applied to the current instance.

Type: Int64

static const STATUS_INSUFFICIENT_STORAGE

public static const STATUS_INSUFFICIENT_STORAGE: UInt16 = 507

Description: The server fails to store the content required to fulfill the request.

Type: Int64

static const STATUS_INTERNAL_SERVER_ERROR

public static const STATUS_INTERNAL_SERVER_ERROR: UInt16 = 500

Description: The server encountered an unexpected condition which prevented it from processing the request.

Type: Int64

static const STATUS_LENGTH_REQUIRED

public static const STATUS_LENGTH_REQUIRED: UInt16 = 411

Description: The server refuses to accept the request without a defined Content-Length header.

Type: Int64

static const STATUS_LOCKED

public static const STATUS_LOCKED: UInt16 = 423

Description: The current resource is locked.

Type: Int64

static const STATUS_LOOP_DETECTED

public static const STATUS_LOOP_DETECTED: UInt16 = 508

Description: The server detects infinite recursion when processing a request.

Type: Int64

static const STATUS_METHOD_NOT_ALLOWED

public static const STATUS_METHOD_NOT_ALLOWED: UInt16 = 405

Description: The request function specified in the request line cannot be used to request the response resource.

Type: Int64

static const STATUS_MISDIRECTED_REQUEST

public static const STATUS_MISDIRECTED_REQUEST: UInt16 = 421

Description: The request is directed to a server that cannot generate a response.

Type: Int64

static const STATUS_MOVED_PERMANENTLY

public static const STATUS_MOVED_PERMANENTLY: UInt16 = 301

Description: Assigns a new permanent URI.

Type: Int64

Note:

The requested resource has been assigned a new permanent URI and any future references to this resource will be redirected to this URI.

static const STATUS_MULTIPLE_CHOICES

public static const STATUS_MULTIPLE_CHOICES: UInt16 = 300

Description: The requested resource has a series of optional feedback information. Each feedback has its own address and browser-driven negotiation information.

Type: Int64

Note:

The user or browser can select a preferred address for redirection.

static const STATUS_MULTI_STATUS

public static const STATUS_MULTI_STATUS: UInt16 = 207

Description: The members bound to the DAV have been listed before the (multi-state) response and are not included again.

Type: Int64

static const STATUS_NETWORK_AUTHENTICATION_REQUIRED

public static const STATUS_NETWORK_AUTHENTICATION_REQUIRED: UInt16 = 511

Description: Network authentication is required.

Type: Int64

static const STATUS_NON_AUTHORITATIVE_INFO

public static const STATUS_NON_AUTHORITATIVE_INFO: UInt16 = 203

Description: The server has successfully processed the request.

Type: Int64

Note:

The returned entity header metadata is not a definite set valid on the original server, but a copy from the local or a third party.

static const STATUS_NOT_ACCEPTABLE

public static const STATUS_NOT_ACCEPTABLE: UInt16 = 406

Description: The content characteristics of the requested resource cannot meet the conditions listed in the request header. Therefore, the response entity cannot be generated.

Type: Int64

static const STATUS_NOT_EXTENDED

public static const STATUS_NOT_EXTENDED: UInt16 = 510

Description: The policy required for obtaining resource is not met.

Type: Int64

static const STATUS_NOT_FOUND

public static const STATUS_NOT_FOUND: UInt16 = 404

Description: The request fails because the requested resource is not found on the server.

Type: Int64

static const STATUS_NOT_IMPLEMENTED

public static const STATUS_NOT_IMPLEMENTED: UInt16 = 501

Description: The server does not support a function required to fulfill the request.

Type: Int64

static const STATUS_NOT_MODIFIED

public static const STATUS_NOT_MODIFIED: UInt16 = 304

Description: The requested resource has not been modified. When the server returns this status code, it does not return any resources.

Type: Int64

Note:

The client usually caches the resources that have been accessed. When the client wants to receive the resources that are modified after the specified date, it provides a header to indicate such resources.

static const STATUS_NO_CONTENT

public static const STATUS_NO_CONTENT: UInt16 = 204

Description: The server has successfully fulfilled the request but does not return any content.

Type: Int64

static const STATUS_OK

public static const STATUS_OK: UInt16 = 200

Description: The request has succeeded. The response headers or data body expected by the request will be returned together with the response.

Type: Int64

static const STATUS_PARTIAL_CONTENT

public static const STATUS_PARTIAL_CONTENT: UInt16 = 206

Description: The server has successfully processed some GET requests.

Type: Int64

static const STATUS_PAYMENT_REQUIRED

public static const STATUS_PAYMENT_REQUIRED: UInt16 = 402

Description: Reserves status code for future requirements.

Type: Int64

static const STATUS_PERMANENT_REDIRECT

public static const STATUS_PERMANENT_REDIRECT: UInt16 = 308

Description: The request and all future requests should use the other URI.

Type: Int64

static const STATUS_PRECONDITION_FAILED

public static const STATUS_PRECONDITION_FAILED: UInt16 = 412

Description: One or more preconditions specified in the request header field are not met when the server verifies the preconditions.

Type: Int64

static const STATUS_PRECONDITION_REQUIRED

public static const STATUS_PRECONDITION_REQUIRED: UInt16 = 428

Description: Specifies some preconditions that must be met when the client sends an HTTP request.

Type: Int64

static const STATUS_PROCESSING

public static const STATUS_PROCESSING: UInt16 = 102

Description: The processing continues.

Type: Int64

static const STATUS_PROXY_AUTH_REQUIRED

public static const STATUS_PROXY_AUTH_REQUIRED: UInt16 = 407

Description: Identity authentication must be performed on the proxy server.

Type: Int64

static const STATUS_REQUESTED_RANGE_NOT_SATISFIABLE

public static const STATUS_REQUESTED_RANGE_NOT_SATISFIABLE: UInt16 = 416

Description: The requested range is invalid.

Type: Int64

Note:

The request contains the Range request header, and any data range specified in the Range does not overlap the available range of the current resource. In addition, the If-Range request header is not defined in the request.

static const STATUS_REQUEST_CONTENT_TOO_LARGE

public static const STATUS_REQUEST_CONTENT_TOO_LARGE: UInt16 = 413

Description: The size of the entity data submitted in the request exceeds the processing capability of the server.

Type: Int64

static const STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE

public static const STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE: UInt16 = 431

Description: The request header field is too large.

Type: Int64

static const STATUS_REQUEST_TIMEOUT

public static const STATUS_REQUEST_TIMEOUT: UInt16 = 408

Description: The request times out. The client fails to send a request within the waiting time of the server.

Type: Int64

static const STATUS_REQUEST_URI_TOO_LONG

public static const STATUS_REQUEST_URI_TOO_LONG: UInt16 = 414

Description: The URI length of the request exceeds the length that the server can interpret.

Type: Int64

static const STATUS_RESET_CONTENT

public static const STATUS_RESET_CONTENT: UInt16 = 205

Description: The server successfully processes the request and does not return any content. The requester is expected to reset the document view.

Type: Int64

static const STATUS_SEE_OTHER

public static const STATUS_SEE_OTHER: UInt16 = 303

Description: The response to the current request can be found on the other URL, and the client should access the resource using GET method.

Type: Int64

static const STATUS_SERVICE_UNAVAILABLE

public static const STATUS_SERVICE_UNAVAILABLE: UInt16 = 503

Description: The server is temporarily maintained or overloaded.

Type: Int64

static const STATUS_SWITCHING_PROTOCOLS

public static const STATUS_SWITCHING_PROTOCOLS: UInt16 = 101

Description: The server understands the client's request and uses the Upgrade header field to instruct the client to use different protocols to fulfill the request.

Type: Int64

Note:

After sending the last blank line of the response, the server switches to the protocols defined in the Upgrade message header.

static const STATUS_TEAPOT

public static const STATUS_TEAPOT: UInt16 = 418

Description: The server cannot process the request and sends a status code called "I am a teapot" to the client. This code should not be taken seriously.

Type: Int64

static const STATUS_TEMPORARY_REDIRECT

public static const STATUS_TEMPORARY_REDIRECT: UInt16 = 307

Description: Performs temporary redirection.

Type: Int64

static const STATUS_TOO_EARLY

public static const STATUS_TOO_EARLY: UInt16 = 425

Description: The server is unwilling to take risks to process the request.

Type: Int64

static const STATUS_TOO_MANY_REQUESTS

public static const STATUS_TOO_MANY_REQUESTS: UInt16 = 429

Description: There are too many requests.

Type: Int64

static const STATUS_UNAUTHORIZED

public static const STATUS_UNAUTHORIZED: UInt16 = 401

Description: The request requires user authentication.

Type: Int64

public static const STATUS_UNAVAILABLE_FOR_LEGAL_REASONS: UInt16 = 451

Description: The request is unavailable for legal reasons.

Type: Int64

static const STATUS_UNPROCESSABLE_ENTITY

public static const STATUS_UNPROCESSABLE_ENTITY: UInt16 = 422

Description: The format of the request is correct, but no response is given due to semantic errors.

Type: Int64

static const STATUS_UNSUPPORTED_MEDIA_TYPE

public static const STATUS_UNSUPPORTED_MEDIA_TYPE: UInt16 = 415

Description: The server does not support the media format in the request.

Type: Int64

Note:

The request is refused because the entity of the request is in a format not supported by the server in terms of the current request function and requested resources.

static const STATUS_UPGRADE_REQUIRED

public static const STATUS_UPGRADE_REQUIRED: UInt16 = 426

Description: The server rejects the request sent by the client using the current protocol, but can accept the request sent by using an upgraded protocol.

Type: Int64

static const STATUS_USE_PROXY

public static const STATUS_USE_PROXY: UInt16 = 305

Description: Uses a proxy. The requested resource must be accessed through a proxy.

Type: Int64

static const STATUS_VARIANT_ALSO_NEGOTIATES

public static const STATUS_VARIANT_ALSO_NEGOTIATES: UInt16 = 506

Description: An internal configuration error occurs on the server.

Type: Int64

struct ServicePoolConfig

public struct ServicePoolConfig

Description: Configures the HTTP Server coroutine pool.

Note:

Each time an HTTP/1.1 Server receives a request, it obtains a coroutine from the pool for processing. If the task waiting queue is full, the request is rejected and the connection is interrupted. An HTTP/2 Server obtains several coroutines from the pool for processing. If the task waiting queue is full, the processing is blocked until there are idle coroutines.

let capacity

public let capacity: Int64

Description: Obtains the coroutine pool capacity.

Type: Int64

let preheat

public let preheat: Int64

Description: Obtains the number of coroutines that are started before the service is started.

Type: Int64

let queueCapacity

public let queueCapacity: Int64

Description: Obtains the maximum number of waiting tasks in the buffer.

Type: Int64

init(Int64, Int64, Int64)

public init(
    capacity!: Int64 = 10 ** 4,
    queueCapacity!: Int64 = 10 ** 4,
    preheat!: Int64 = 0
)

Description: Constructs a ServicePoolConfig instance.

Parameters:

  • capacity!: Int64: coroutine pool capacity. The default value is 10000.
  • queueCapacity!: Int64: maximum number of waiting tasks in the buffer. The default value is 10000.
  • preheat!: Int64: number of coroutines that are started before the service is started. The default value is 0.

Throws:

  • IllegalArgumentException: If the value of capacity, queueCapacity, or preheat is less than 0, or the value of preheat is greater than that of capacity, this exception is thrown.

struct TransportConfig

public struct TransportConfig

Description: Specifies a transport layer configuration class used by the server to establish a connection.

prop keepAliveConfig

public mut prop keepAliveConfig: SocketKeepAliveConfig

Description: Sets and reads the message keepalive configuration of the connection at the transport layer. The default idle time for configuration is 45s, the interval for sending probe packets is 5s, and the number of probe packets sent before the connection is considered invalid is 5. The actual time granularity may vary according to the operating system.

Type: SocketKeepAliveConfig

prop readBufferSize

public mut prop readBufferSize: ?Int64

Description: Sets and reads the read buffer size of the connection at the transport layer. The default value is None. If the value is less than 0, IllegalArgumentException is thrown after the server service connection is established.

Note:

When the default value is used, the actual buffer size is determined by the operating system.

Type: ?Int64

prop readTimeout

public mut prop readTimeout: Duration

Description: Sets and reads the read timeout of the connection at the transport layer. If the value is less than 0, it is set to 0. The default value is Duration.Max.

Type: Duration

prop writeBufferSize

public mut prop writeBufferSize: ?Int64

Description: Sets and reads the write buffer size of the connection at the transport layer. The default value is None. If the value is less than 0, IllegalArgumentException is thrown after the server service connection is established.

Note:

When the default value is used, the actual buffer size is determined by the operating system.

Type: ?Int64

prop writeTimeout

public mut prop writeTimeout: Duration

Description: Sets and reads the write timeout of the connection at the transport layer. If the value is less than 0, it is set to 0. The default value is Duration.Max.

Type: Duration