HttpRequest

open class HttpRequest

A cross-platform HTTP API modeled after XMLHttpRequest. Supports streaming of request and response content.

Example:
open fun classExample(): kotlin.Unit
{
    val request = com.sap.cloud.mobile.kotlin.odata.http.HttpRequest();
    request.open(com.sap.cloud.mobile.kotlin.odata.http.HttpMethod.GET,
        "http://google.com");
    request.send();
    val text = request.responseText;
    request.close();
    Example.show("google.com home page text: ", text);
}

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var status: Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var url: String
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open fun close()

Close this HTTP request, and any response stream that may have been opened by {@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#send() HttpRequest.send}. If an application calls {@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#send() HttpRequest.send}, then it must also call this function to avoid resource leaks.

Link copied to clipboard
open fun enableTrace(serviceName: String?, traceRequest: Boolean, traceHeaders: Boolean, traceContent: Boolean, prettyPrint: Boolean)

Enable HTTP request tracing. Call this before calling {@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#send() HttpRequest.send}.

Link copied to clipboard
open fun getRequestCookie(name: String): String?

Get a request cookie value. For use by servers.

See Also:

{@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#requestCookies HttpRequest.requestCookies}.

Link copied to clipboard
open fun getRequestHeader(name: String): String?

Get a request header value. For use by servers.

See Also:

{@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#requestHeaders HttpRequest.requestHeaders}.

Link copied to clipboard
open fun getResponseCookie(name: String): String?

Get a response cookie value. Call this after calling {@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#send() HttpRequest.send}.

See Also:

{@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#responseCookies HttpRequest.responseCookies}.

Link copied to clipboard
open fun getResponseHeader(name: String): String?

Get a response header value. Call this after calling {@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#send() HttpRequest.send}.

See Also:

{@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#responseHeaders HttpRequest.responseHeaders}.

Link copied to clipboard
open fun login(username: String, password: String)

Specify the HTTP basic credentials. Call this before calling {@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#send() HttpRequest.send} if the server requires HTTP basic authentication.

Link copied to clipboard
open fun open(method: String, url: String)

Specify the HTTP {@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#method HttpRequest.method} and {@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#url HttpRequest.url}. Call this before calling {@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#send() HttpRequest.send}.

Link copied to clipboard
open fun send()

Send this HTTP request to the server, and wait for a response. If {@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#streamResponse HttpRequest.streamResponse} is true, then waiting is only until response headers come back, and response content may be streamed as it is accessed. If an application calls this function, then it must also call {@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#close() HttpRequest.close} after accessing all desired response content, to avoid resource leaks.

See Also:

{@link com.sap.cloud.mobile.kotlin.odata.http.HttpException}.

Link copied to clipboard
Link copied to clipboard
open fun setRequestCookie(name: String, value: String)

Set a request cookie. Call this before calling {@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#send() HttpRequest.send}.

See Also:

{@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#requestCookies HttpRequest.requestCookies}.

Link copied to clipboard
open fun setRequestHeader(name: String, value: String)

Set a request header. Call this before calling {@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#send() HttpRequest.send}.

See Also:

{@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#requestHeaders HttpRequest.requestHeaders}.

Link copied to clipboard
open fun setResponseCookie(name: String, value: String)

Set a response cookie. For use by servers.

See Also:

{@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#responseCookies HttpRequest.responseCookies}.

Link copied to clipboard
open fun setResponseHeader(name: String, value: String)

Set a response header. For use by servers.

See Also:

{@link com.sap.cloud.mobile.kotlin.odata.http.HttpRequest#responseHeaders HttpRequest.responseHeaders}.