Skip to content

API > HttpClient


HttpClient⚓︎

The HttpClient class simplifies HTTP communication in the Massive Loop, offering a set of features for sending requests and handling responses.

Members⚓︎

Properties⚓︎

Name Description
HttpClient.UseCookiesProperty Enables the client to store cookies set by web servers and use them when sending subsequent web requests.
HttpClient.UseDefaultHeadersProperty Uses the default headers if set to true.
HttpClient.UseDefaultUserAgentProperty Sets a default user agent to the client.
HttpClient.UseDeflateDecompressionProperty Enables using the Deflate Decompression.
HttpClient.UseGZipDecompressionProperty Enables using the GZip Decompression.

Constructor⚓︎

Name Description
HttpClient()Constructor Creates a new HttpClient.

Methods⚓︎

Name Description
HttpClient.AddCookie(domain, Name, value) Method Add a new cookie to the list of cookies used by the Http Client.
HttpClient.AddCustomUserAgent(User agent) Method Add a new custom user agent. The user agent needs to be in proper format of ProductName/ProductVersion
HttpClient.AddUserAgentProductInfo(name, version) Method Adds a new user agent with product name and product version.
HttpClient.ClearUserAgent() Method Clears the current User Agent header.
HttpClient.GetCookies(domain) Method Returns an array of KeyValues of cookies currently set in http client for the specific domain.
HttpClient.WebRequest(url, httpMethod, extraHeaders=Nil) Method Sends a new Web Request without content. A URL and a HTTP Method are required.
HttpClient.WebRequest(url, method, content[], extraHeaders=Nil) Method Sends a new Web Request with a byte array content. A URL, HTTP Method and a byte array (number array) are required.
HttpClient.WebRequest(url, method, content, extraHeaders=Nil) Method Sends a new Wen Request with a string content. A URL, HTTP Method and a string are required.
HttpClient.WebRequest(url, method, table, extraHeaders=Nil) Method Sends a new Wen Request with Json content. A URL, HTTP Method and an object are required. The Object will be serialized to Json string internally.

Extra Detail⚓︎

In Massive Loop, you can only send web requests to URLs which are whitelisted by the Massive Loop server admin. The URL path needs to be fully defined in the server. For example, to make a web request to http://foo.com/custom/path/a and http://foo.com/custom/path/b, both paths need to be registered in the massive loop server settings.

HttpClient by default contains settings to make basic Json requests, however, these settings can be overridden. These settings are as follows: UseGZipDecompression=true UseDeflateDecompression=true UseDefaultHeaders=true { User-Agent: Mozilla/5.0 AppleWebKit/537.36 Chrome/42.0.2311.135 Safari/537.36 Edge/12.246 Content-Type: application/json }