Skip to main content

HttpService

ZEPETO.Multiplay.HttpService.HttpService

HttpService provides an API to establish HTTP connections with external web services and make requests.

  • Ensure using HTTPS protocol; HTTP is supported only in the development environment.
  • Requests are limited to ports 80 and 443.
  • The maximum size for request and response bodies is 16KB.
  • Keep requests per minute below 500 to avoid potential limitations on the World service due to excessive requests.
  • Requests will fail if external web services do not respond within 5 seconds.
  • Ensure that the Content-Type in response headers matches values defined in HttpContentType enum to prevent request failures.
  • Due to potential web request failures for various reasons, it's recommended to code defensively.

Methods

getAsync

getAsync(url, headers?): Promise<HttpResponse>

Asynchronously performs an HTTP GET request. Throws HttpError.

Parameters

NameTypeDescription
urlstringThe web address to send the request.
headers?HttpHeaderOptional HTTP request headers. (Optional)

Returns

Promise<HttpResponse>

Promise resolved with the HttpResponse object upon completion.


postAsync

postAsync(url, body, headers?): Promise<HttpResponse>

Perform HTTP POST requests asynchronously. Throws HttpError.

Parameters

NameTypeDescription
urlstringThe web address to send the request.
bodyHttpBodyTypeRequest body content.
headers?HttpHeaderOptional HTTP request headers. (Optional)

Returns

Promise<HttpResponse>

Promise resolved with the HttpResponse object upon completion.

postAsync(url, body, httpContentType, headers?): Promise<HttpResponse>

Perform HTTP POST requests asynchronously. Throws HttpError. When using this signature, if you add 'Content-Type' to headers, it will be overwritten by what is specified in httpContentType.

Parameters

NameTypeDescription
urlstringThe web address to send the request.
bodyHttpBodyTypeRequest body content.
httpContentTypeHttpContentTypeSpecifies the request Content-Type header.
headers?HttpHeaderOptional HTTP request headers. (Optional)

Returns

Promise<HttpResponse>

Promise resolved with the HttpResponse object upon completion.