JavaFX: Bringing Rich Experiences To All the Screens Of Your Life

Profile: desktop, common

Overview

An API to make asynchronous HTTP requests. Can also be to invoke RESTful Web Services.

HttpRequest allows one to specify a location and method and start a HTTP operation with the function start(). Various variables such as started, connecting, writing, reading and done will change state as the operation progresses. For operations that transfer large amounts of data, the percentage progress can be computed using the read, toread, written and towrite variables. Callback functions are also called to indicate changes in state as the operation progresses.

Performing a GET request

The example snippet below performs a HTTP GET request and prints changes in state to the console.

def getRequest: HttpRequest = HttpRequest {

    location: "http://www.wikipedia.org";

    onStarted: function() {
        println("onStarted - started performing method: {getRequest.method} on location: {getRequest.location}");
    }

    onConnecting: function() { println("onConnecting") }
    onDoneConnect: function() { println("onDoneConnect") }
    onReadingHeaders: function() { println("onReadingHeaders") }
    onResponseCode: function(code:Integer) { println("onResponseCode - responseCode: {code}") }
    onResponseMessage: function(msg:String) { println("onResponseMessage - responseMessage: {msg}") }

    onResponseHeaders: function(headerNames: String[]) {
        println("onResponseHeaders - there are {headerNames.size()} response headers:");
        for (name in headerNames) {
            println("    {name}: {getRequest.getResponseHeaderValue(name)}");
        }
    }

    onReading: function() { println("onReading") }

    onToRead: function(bytes: Long) {
        if (bytes < 0) {
            println("onToRead - Content length not specified by server; bytes: {bytes}");
        } else {
            println("onToRead - total number of content bytes to read: {bytes}");
        }
    }

    // The onRead callback is called when some data has been read.  If an
    // output stream is provided in the sink variable, onRead shows the progress
    // of bytes read from location and written to the sink.  If no value is
    // specified for the sink variable, the onRead callback shows the progress of
    // bytes read from location to a buffer allocated by HttpRequest.  These bytes
    // will be made available when the reading is complete, in the form of an
    // input stream provided by the onInput callback.
    onRead: function(bytes: Long) {
        // The toread variable is non negative only if the server provides the content length
        def progress =
        if (getRequest.toread > 0) "({(bytes * 100 / getRequest.toread)}%)" else "";
        println("onRead - bytes read: {bytes} {progress}");
    }

    // The content of a response can be accessed in the onInput callback function.
    // Be sure to close the input sream when finished with it in order to allow
    // the HttpRequest implementation to clean up resources related to this
    // request as promptly as possible.
    onInput: function(is: java.io.InputStream) {
        // use input stream to access content here.
        // can use input.available() to see how many bytes are available.
        try {
            println("onInput - bytes of content available: {is.available()}");
        } finally {
            is.close();
        }
    }

    onException: function(ex: java.lang.Exception) {
        println("onException - exception: {ex.getClass()} {ex.getMessage()}");
    }

    onDoneRead: function() { println("onDoneRead") }
    onDone: function() { println("onDone") }
}

getRequest.start();

The above snippet would print on the console -

onStarted - started performing method: GET on location: http://www.wikipedia.org
onConnecting
onDoneConnect
onReadingHeaders
onResponseCode - responseCode: 200
onResponseMessage - responseMessage: OK
onResponseHeaders - there are 12 response headers:
    date: Wed, 17 Dec 2008 19:26:37 GMT
    server: Apache
    x-powered-by: PHP/5.2.4-2ubuntu5wm1
    cache-control: s-maxage=3600, must-revalidate, max-age=0
    last-modified: Thu, 11 Dec 2008 09:19:49 GMT
    content-type: text/html; charset=utf-8
    content-length: 51605
    x-cache: HIT from sq17.wikimedia.org
    x-cache-lookup: HIT from sq17.wikimedia.org:80
    age: 2
    via: 1.0 sq27.wikimedia.org:3128 (squid/2.6.STABLE21), 1.0 sq17.wikimedia.org:80 (squid/2.6.STABLE21)
    connection: keep-alive
onReading
onToRead - total number of content bytes to read: 51605
onRead - bytes read: 2023 (3%)
onRead - bytes read: 4631 (8%)
onRead - bytes read: 5935 (11%)
onRead - bytes read: 7239 (14%)
onRead - bytes read: 9847 (19%)
onRead - bytes read: 12455 (24%)
onRead - bytes read: 15063 (29%)
onRead - bytes read: 18975 (36%)
onRead - bytes read: 22887 (44%)
onRead - bytes read: 24191 (46%)
onRead - bytes read: 26799 (51%)
onRead - bytes read: 28103 (54%)
onRead - bytes read: 32015 (62%)
onRead - bytes read: 35927 (69%)
onRead - bytes read: 37231 (72%)
onRead - bytes read: 41327 (80%)
onRead - bytes read: 42447 (82%)
onRead - bytes read: 46543 (90%)
onRead - bytes read: 47663 (92%)
onRead - bytes read: 50271 (97%)
onRead - bytes read: 51605 (100%)
onInput - bytes of content available: 51605
onDoneRead
onDone

If the user enters a puposefully unknown host in the URL, such as: http://www.sun.comunknown.host/, the resulting output will look like this:

onStarted - started performing method: GET on location: http://www.sun.comunknown.host/
onConnecting
onException - exception: class java.net.UnknownHostException www.sun.comunknown.host
onDone

Life cycle

Progress of the HttpRequest operation life cycle is tracked by changes in variable values and associated callback variables, if specified.

Sequence of changes to variable values for a HTTP GET request operation.

variable name and callback function variable name initial or previous variable value new value description
1 started, onStarted false true Indicates that the HTTP request has started execution.
2 connecting, onConnecting false true Indicates that the HTTP request will now attempt to connect to location.
3 doneConnect, onDoneConnect false true HTTP connection to location has been opened successfully.
4 readingHeaders, onReadingHeaders false true Indicates that the HTTP request will now attempt to read HTTP response headers from location.
5 responseCode, onResponseCode 0 HTTP Response code (Integer) The HTTP response code has been read.
6 responseMessage, onResponseMessage null HTTP Response message (String) The HTTP response message has been read.
[6.a] error, onError null error stream (InputStream) An error response is available (only if provided in HTTP response).
7 doneHeaders, onDoneHeaders false true HTTP response headers have been read.
8 reading, onReading false true About to start reading the HTTP response body.
[8.a] toread, onToRead 0 bytes to read (Long) toread bytes of content available to be read.
[8.b] read, onRead 0 bytes read (Long) read bytes of content that has just been read. (shows read progress)
9 input, onInput null response body (InputStream) An InputStream providing access to the HTTP response body.
10 doneRead, onDoneRead false true The entire HTTP response body has been read.
11 done, onDone false true The HTTP operation has finished.

Peforming a POST request

The example snippet below performs a HTTP POST request and prints changes in state to the console. It posts some abitrary content to a fictitious Servlet (TestServlet) that runs on the local host.


def testContent: String = "test content";
def testContentSize: Integer = testContent.getBytes().length;

def postRequest: HttpRequest = HttpRequest {

    location: "http://localhost:8080/TestServlet/";

    method: HttpRequest.POST;

    headers: [
        HttpHeader {
            name: HttpHeader.CONTENT_TYPE;
            value: "somecontent/type";
        },
        HttpHeader {
            name: HttpHeader.CONTENT_LENGTH;
            value: "{testContentSize}";
        }
    ];

    onStarted: function() {
        println("onStarted - started performing method: {postRequest.method} on location: {postRequest.location}");
    }

    onConnecting: function() { println("onConnecting") }
    onDoneConnect: function() { println("onDoneConnect") }
    onWriting: function() { println("onWriting") }

    // The content of a PUT or POST can be specified in the onOutput callback function.
    // Be sure to close the output sream when finished with it in order to allow
    // the HttpRequest implementation to clean up resources related to this
    // request as promptly as possible.  The calling next callback (onToWrite) depends
    // the output stream being closed.
    onOutput: function(os: java.io.OutputStream) {
        try {
            println("onOutput - about to write {testContentSize} bytes to output stream");
            os.write(testContent.getBytes());
        } finally {
            println("onOutput - about to close output stream.");
            os.close();
        }
    }

    onToWrite: function(bytes: Long) { println("onToWrite - entire content to be written: {bytes} bytes") }
    onWritten: function(bytes: Long) { println("onWritten - {bytes} bytes has now been written") }
    onDoneWrite: function() { println("doneWrite") }
    onReadingHeaders: function() { println("onReadingHeaders") }
    onResponseCode: function(code:Integer) { println("onResponseCode - responseCode: {code}") }
    onResponseMessage: function(msg:String) { println("onResponseMessage - responseMessage: {msg}") }

    onResponseHeaders: function(headerNames: String[]) {
        println("onResponseHeaders - there are {headerNames.size()} response headers:");
        for (name in headerNames) {
            println("    {name}: {postRequest.getResponseHeaderValue(name)}");
        }
    }

    onReading: function() { println("onReading") }

    onToRead: function(bytes: Long) {
        if (bytes < 0) {
            println("onToRead - Content length not specified by server; bytes: {bytes}");
        } else {
            println("onToRead - total number of content bytes to read: {bytes}");
        }
    }

    // The onRead callback is called when some more data has been read into
    // the input stream's buffer.  The input stream will not be available until
    // the onInput call back is called, but onRead can be used to show the
    // progress of reading the content from the location.
    onRead: function(bytes: Long) {
        // The toread variable is non negative only if the server provides the content length
        def progress =
        if (postRequest.toread > 0) "({(bytes * 100 / postRequest.toread)}%)" else "";
        println("onRead - bytes read: {bytes} {progress}");
    }

    // The content of a response can be accessed in the onInput callback function.
    // Be sure to close the input sream when finished with it in order to allow
    // the HttpRequest implementation to clean up resources related to this
    // request as promptly as possible.
    onInput: function(is: java.io.InputStream) {
        // use input stream to access content here.
        // can use input.available() to see how many bytes are available.
        try {
            println("onInput - bytes of content available: {is.available()}");
        } finally {
            is.close();
        }
    }

    onException: function(ex: java.lang.Exception) {
        println("onException - exception: {ex.getClass()} {ex.getMessage()}");
    }

    onDoneRead: function() { println("onDoneRead") }
    onDone: function() { println("onDone") }
};

postRequest.start();

The above snippet would print on the console -


onStarted - started performing method: POST on location: http://localhost:8080/TestServlet/
onConnecting
onDoneConnect
onWriting
onOutput() about to write 12 bytes to output stream
onOutput() about to close output stream.
onToWrite - entire content to be written: 12 bytes
onWritten - 12 bytes has now been written
doneWrite
onReadingHeaders
onResponseCode - responseCode: 200
onResponseMessage - responseMessage: OK
onResponseHeaders - there are 6 response headers:
    x-powered-by: JSP/2.1
    server: GlassFish/v3
    set-cookie: JSESSIONID=c7356338c17a201e00f3acf90271; Path=/TestServlet
    content-type: text/html;charset=UTF-8
    content-length: 325
    date: Mon, 15 Dec 2008 21:00:38 GMT
onReading
onToRead - total number of content bytes to read: 325
onRead - bytes read: 325 (100%)
onInput - bytes of content available: 325
onDoneRead
onDone

Sequence of changes to variable values for a HTTP POST or PUT request operation.

variable name and callback function variable name initial or previous variable value new value description
1 started, onStarted false true Indicates that the HTTP request has started execution.
2 connecting, onConnecting false true Indicates that the HTTP connection to location has started.
3 doneConnect, onDoneConnect false true HTTP connection to location has been opened successfully.
4 writing, onWriting false true The writing of request content is about to start.
[4.a] output, onOutput null an OutputStream Output stream availalbe for writing request content. Writing of content to the HTTP connection will only happen after OutputStream.close() is called.
[4.b] towrite, onToWrite 0 bytes to write (Long) towrite bytes of content is about to be written to location. This is the number of bytes contained in the output stream output at the time OutputStream.close() is called.
[4.c] written, onWritten 0 bytes written (Long) written bytes of content has been written (shows write progress).
[4.d] doneWrite, onDoneWrite false true The entire HTTP request body has been written
5 readingHeaders, onReadingHeaders false true Indicates that the HTTP request will now attempt to read HTTP response headers from location.
6 responseCode, onResponseCode 0 HTTP Response code (Integer) The HTTP response code has been read.
7 responseMessage, onResponseMessage null HTTP Response message (String) The HTTP response message has been read.
[7.a] error, onError null error stream (InputStream) An error response is available (only if provided in HTTP response).
8 doneHeaders, onDoneHeaders false true HTTP response headers have been read.
9 reading, onReading false true About to start reading the HTTP response body.
[9.a] toread, onToRead 0 bytes to read (Long) toread bytes of content available to be read.
[9.b] read, onRead 0 bytes read (Long) read bytes of content that has just been read. (shows read progress)
10 input, onInput null response body (InputStream) An InputStream providing access to the HTTP response body.
11 doneRead, onDoneRead false true The entire HTTP response body has been read.
12 done, onDone false true The HTTP operation has finished.

Sequence of changes to variable values for a HTTP DELETE request operation.

variable name and callback function variable name initial or previous variable value new value description
1 started, onStarted false true Indicates that the HTTP request has started execution.
2 connecting, onConnecting false true Indicates that the HTTP connection to location has started.
3 doneConnect, onDoneConnect false true HTTP connection to location has been opened successfully.
4 readingHeaders, onReadingHeaders false true Indicates that the HTTP request will now attempt to read HTTP response headers from location.
5 responseCode, onResponseCode 0 HTTP Response code (Integer) The HTTP response code has been read.
6 responseMessage, onResponseMessage null HTTP Response message (String) The HTTP response message has been read.
[6.a] error, onError null error stream (InputStream) An error response is available (only if provided in HTTP response).
7 doneHeaders, onDoneHeaders false true HTTP response headers have been read.
8 done, onDone false true The HTTP operation has finished.

Error Handling

At any time after calling start(), the exception variable can be assigned an exception. This indicates that there has been an error in the processing of the HttpRequest's operation. Subsequently, the done variable will be assigned the value true, indicating the end of execution of the HttpRequest's operation. In all cases after start() has been called, the last event to happen will be the assignment of true to the done variable.

Canceling a HTTP operation

A request's HTTP operation can be cancelled by calling cancel() at any time after start() has been called. This removes the request from the queue if it is queued, or interrupts the request if it has started executing. Both of these cases will cause the done variable to change value to true.

Profile: common

Script Variable Summary

access name type Can Read Can Init Can Write Default Value description
public DELETE String

HTTP DELETE method value.

HTTP DELETE method value. Can be assigned to method

&nbsp;
public GET String

HTTP GET method value.

HTTP GET method value. Can be assigned to method

&nbsp;
public POST String

HTTP POST method value.

HTTP POST method value. Can be assigned to method

&nbsp;
public PUT String

HTTP PUT method value.

HTTP PUT method value. Can be assigned to method

&nbsp;

Variable Summary

access name type Can Read Can Init Can Write Default Value description
public-read protected connecting Boolean subclass subclass false

Indicates that the request is attempting to connect to location.

public context Object null

Context object provided by appliction.

Context object provided by appliction. To be provided by and used by the application during asynchronus events as this request progresses. If context is assigned another HttPRequest object, it can be accessed from a trigger for the done variable to "chain" HTTP operations. Once this HttpRequest's operation is done, the one contained in context can be #start()ed.

null

See Also:
start(), done

&nbsp;
public-read protected doneConnect Boolean subclass subclass false

Indicates that the HTTP connection to location has been opened successfully.

public-read protected doneHeaders Boolean subclass subclass false

Indicates that the HTTP headers have successfully been read from location.

Indicates that the HTTP headers have successfully been read from location. These HTTP headers are availalbe via getResponseHeaderNames() and getResponseHeaderValue(String) if the value is true.

false

See Also:
onDoneHeaders

&nbsp;
public-read protected doneRead Boolean subclass subclass false

Indicates if reading of response content from location has finished.

Indicates if reading of response content from location has finished. The content has been stored in input if the value is true.

false &nbsp;
public-read protected doneWrite Boolean subclass subclass false

Indicates that the contents of output have been successfully written to location.

public-read protected error InputStream subclass subclass null

Contains the error content for this request.

Contains the error content for this request. This variable gets assigned an input stream only if error content has been received from location.

null &nbsp;
public-read protected exception Exception subclass subclass null

Contains an exception indicating an error occured with this request.

Contains an exception indicating an error occured with this request. This variable gets assigned an excception only if an exception is encountered during communication with location for this request. If this variable gets assigned an exception, the done variable will subsequently get assigned the value true.

null &nbsp;
public headers HttpHeader[] null

A map of HTTP request headers to send to the location.

public-read protected id Integer subclass subclass 0

Unique HTTP operation identifier for this request.

Unique HTTP operation identifier for this request. Assigned only as a result of calling the start() function.

0 &nbsp;
public-read protected input InputStream subclass subclass null

Contains the response content for this request.

Contains the response content for this request. This variable gets assigned an input stream only after the entire content of the request has been received from location.

null &nbsp;
public location String null

Target location for this HttpRequest.

Target location for this HttpRequest. URL format.

null &nbsp;
public method String GET

Method to use for this request.

Method to use for this request. One of GET, POST, PUT, DELETE

GET &nbsp;
public onConnecting function():Void null

Callback that is invoked once to indicate that the request is attempting to connect to location.

public onDoneConnect function():Void null

Callback that is invoked once to indicate that the request is now connected to location.

public onDoneHeaders function():Void null

Callback that is invoked once to indicate that the request is done reading response headers.

Callback that is invoked once to indicate that the request is done reading response headers. responseCode, responseMessage and error, if sent, are also available at this time.

null &nbsp;
public onDoneRead function():Void null

Callback that is invoked once to indicate that the request is done reading the response body.

public onDoneWrite function():Void null

Callback that is invoked once to indicate that the request is done writing and all of the data in output has been sent to location.

public onError function(:InputStream):Void null

Callback that is invoked once to indicate that an InputStream containing an error response from the server is now available.

Callback that is invoked once to indicate that an InputStream containing an error response from the server is now available. The provided InputStream must be closed when done reading in a finally block -

 try {
     // read from input
 } finally {
     input.close();
 }
 

null &nbsp;
public onException function(:Exception):Void null

Callback that is invoked once to provide an application with an exception that occurred, if any, during the execution of this request.

public onInput function(:InputStream):Void null

Callback that is invoked once to indicate that the request body is now available.

Callback that is invoked once to indicate that the request body is now available. The provided InputStream must be closed when done reading in a finally block -

 try {
     // read from input, hand-off to a parser, etc
 } finally {
     input.close();
 }
 

null &nbsp;
public onOutput function(:OutputStream):Void null

Callback that is invoked once to provide an application with an opportunity to write data that is to be sent to location.

Callback that is invoked once to provide an application with an opportunity to write data that is to be sent to location. Valid for POST and PUT. To keep the application from blocking, the data is first accumulated in memory and sent after an application closes the OutputStream provided. The provided OutputStream must be closed to initiate the transfer, so wrapping the writes in a finally block is recommended -

 try {
     // write to output
 } finally {
     output.close();
 }
 

null &nbsp;
public onRead function(:long):Void null

Callback that is invoked to indicate the number of bytes read so far.

public onReading function():Void null

Callback that is invoked once to indicate that the request is starting to read the response body.

public onReadingHeaders function():Void null

Callback that is invoked once to indicate that the request is starting to read HTTP reponse headers, responseCode, responseMessage and error, if any.

public onResponseCode function(:int):Void null

Callback that is invoked once to indicate that the HTTP response code from the server is now available.

Callback that is invoked once to indicate that the HTTP response code from the server is now available. Some commonly used HTTP response codes are defined in HttpStatus and can be used to compare with.

null &nbsp;
public onResponseHeaders function(:Sequence):Void null

Callback that is invoked once to indicate that HTTP response headers from the server are now available.

Callback that is invoked once to indicate that HTTP response headers from the server are now available. Some commonly used HTTP headers are defined in HttpHeader and can be used to compare with.

null &nbsp;
public onResponseMessage function(:String):Void null

Callback that is invoked once to indicate that the HTTP response message from the server is now available.

public onStarted function():Void null

Callback that is invoked once to indicate that the request has started execution.

public onToRead function(:long):Void null

Callback that is invoked once to indicate the total number of bytes to read, if available.

Callback that is invoked once to indicate the total number of bytes to read, if available. This is usually the value of the content-length HTTP header, if set by the server.

null

See Also:
toread

&nbsp;
public onToWrite function(:long):Void null

Callback that is invoked once to indicate the total number of bytes to write.

public onWriting function():Void null

Callback that is invoked once to indicate that the request has started writing the data previously written to output by the application to location.

public onWritten function(:long):Void null

Callback that is invoked to indicate the number of bytes written so far.

public-read protected output OutputStream subclass subclass null

Contains data to be written to location during HTTP operations where method contains POST or PUT.

public-read protected read Long subclass subclass 0

Number bytes read from the location into input.

public-read protected reading Boolean subclass subclass false

Indicates if reading response content from location is about to start.

public-read protected readingHeaders Boolean subclass subclass false

Indicates that the reading of HTTP headers from location has started.

public-read protected responseCode Integer subclass subclass null

The HTTP response code to the request method from location.

The HTTP response code to the request method from location. Usually included in responseMessage

null &nbsp;
public-read protected responseHeaders HttpHeader[] subclass subclass null

A map of HTTP headers provided in response to the request method from location.

public-read protected responseMessage String subclass subclass null

The HTTP response message to the request method from location.

The HTTP response message to the request method from location. Usually includes the text representation of the responseCode

null &nbsp;
public-init protected sink OutputStream subclass
public-init protected source InputStream subclass
public-read protected toread Long subclass subclass 0

Number of bytes expected to be read from input.

Number of bytes expected to be read from input. The number of bytes available in input when input is first made available, if content-length is set.

0

See Also:
onToRead

&nbsp;
public-read protected towrite Long subclass subclass 0

The number of bytes already in output that are going to be written to location.

public-read protected writing Boolean subclass subclass false

Indicates that the contents of output are about to be written to location.

public-read protected written Long subclass subclass 0

Number of bytes in output that have been written to location.

Inherited Variables

javafx.async.Task

access name type Can Read Can Init Can Write Default Value description
public-read protected causeOfFailure Object subclass subclass null

Indicates the cause of failure of this task.

Indicates the cause of failure of this task. If this variable's value is null, there is no known cause of failure, even if the failed variable is set to true. If this variable's value is not null, it will most likely contain an exception that describes the cause of failure.

null

See Also:
failed

Profile: common

&nbsp;
public-read protected done Boolean subclass subclass false

Indicates if this task has completed.

Indicates if this task has completed. This is the last of the variables started, stopped, failed, succeeded and causeOfFailure to be modified. This variable is to be set to true upon completion of this task, without respect to success or failure of the task..

false

Profile: common

&nbsp;
public-read protected failed Boolean subclass subclass false

Indicates if this task has failed.

Indicates if this task has failed. This variable is set to true as a result of the task executing and failing by means of an exception. This exception could be the result of the task being stopped by the stop() function being called. causeOfFailure will contian the failure cause if the failure was caused by an exception during execution.

false

See Also:
stop(), causeOfFailure

Profile: common

&nbsp;
public-read protected maxProgress Long subclass subclass -1

Indicates a maximum value for the progress variable.

Indicates a maximum value for the progress variable. If set to zero or a negative value, there is no known maximum and the percentDone variable will not change during the course of execution of this task.

-1

See Also:
progress, percentDone

Profile: common

&nbsp;
public onDone function():Void null

Callback that is invoked once to indicate that the task execution has completed (successfully, or unsuccessfully).

Callback that is invoked once to indicate that the task execution has completed (successfully, or unsuccessfully). This task's implemenation will not modify this task's variables during or after a call to this function. Once the start() function has been called, this function will eventually be called, if it is non-null.

null

See Also:
done, start(), stop()

Profile: common

&nbsp;
public onStart function():Void null

Callback that is invoked once to indicate that the task is about to start execution.

Callback that is invoked once to indicate that the task is about to start execution. This function is not called as a result of the queueing of this task for execution.

null

See Also:
started, start()

Profile: common

&nbsp;
public-read percentDone Number -1

Indicates the current progress of this task in terms of percent complete.

Indicates the current progress of this task in terms of percent complete. Zero or a positive value indicate progress toward completion. This variable's value may or may not change from its default value depending on the specific Task implementation.

-1

See Also:
maxProgress, progress

Profile: common

&nbsp;
public-read protected progress Long subclass subclass -1

Indicates the current progress toward completion of this task.

Indicates the current progress toward completion of this task. Zero or a positive value indicate progress toward completion. This variable's value may or may not change from its default value depending on the specific Task implementation.

-1

See Also:
maxProgress, percentDone

Profile: common

&nbsp;
public-read protected started Boolean subclass subclass false

Indicates if this task has started.

Indicates if this task has started. Once this task's start() function has been called, the task may or may not be queued before it executes. This variable is set to true just before the task starts executing.

false

See Also:
onStart

Profile: common

&nbsp;
public-read protected stopped Boolean subclass subclass false

Indicates if this task has been stopped.

Indicates if this task has been stopped. This variable is set to true as a result of the stop() function being called. A value of true means that the task did not execute to completion, and possibly not at all if the task was queued for execution by stop() and stopped by stop() before execution.

false

See Also:
stop()

Profile: common

&nbsp;
public-read protected succeeded Boolean subclass subclass false

Indicates if this task has successfully completed.

Indicates if this task has successfully completed. This variable is to be set to true upon successful completion of this task, but before the done variable is set to to true.

false

See Also:
done

Profile: common

&nbsp;

Function Summary

public getResponseHeaderNames() : java.lang.Object[]

Get the names of HTTP headers set on the HTTP response.

Get the names of HTTP headers set on the HTTP response.

See Also:
doneHeaders

Returns
Object[]
a sequence of names of HTTP headers set on the HTTP response. Will be an empty sequence if HTTP response headers are not available yet.
&nbsp;
public getResponseHeaderValue(name: java.lang.String) : java.lang.String

Retrieve the value of the specified HTTP header name.

Retrieve the value of the specified HTTP header name. Must be one of the names in the sequence returned from getResponseHeaderNames(). Returns the empty string ("") if the specifed HTTP header is not set on the HTTP response.

Parameters
name
the HTTP response header name whose value is to be retrieved
Returns
String
&nbsp;
public impl_getHeaders() : java.util.Map
Returns
Map
&nbsp;
public impl_getLocation() : java.lang.String
Returns
String
&nbsp;
public impl_getMethod() : java.lang.String
Returns
String
&nbsp;
public impl_getSink() : java.io.OutputStream
Returns
OutputStream
&nbsp;
public impl_getSource() : java.io.InputStream
Returns
InputStream
&nbsp;
public impl_setConnecting() : Void
&nbsp;
public impl_setDone() : Void
&nbsp;
public impl_setDoneConnect() : Void
&nbsp;
public impl_setDoneHeaders() : Void
&nbsp;
public impl_setDoneRead() : Void
&nbsp;
public impl_setDoneStart() : Void
&nbsp;
public impl_setDoneWrite() : Void
&nbsp;
public impl_setError(es: java.io.InputStream) : Void
Parameters
es
&nbsp;
public impl_setException(ex: java.lang.Exception) : Void
Parameters
ex
&nbsp;
public impl_setInput(is: java.io.InputStream) : Void
Parameters
is
&nbsp;
public impl_setOutput(os: java.io.OutputStream) : Void
Parameters
os
&nbsp;
public impl_setRead(bytes: Long) : Void
Parameters
bytes
&nbsp;
public impl_setReading() : Void
&nbsp;
public impl_setReadingHeaders() : Void
&nbsp;
public impl_setResponseCode(code: Integer) : Void
Parameters
code
&nbsp;
public impl_setResponseHeaders(headers: java.util.Map) : Void
Parameters
headers
&nbsp;
public impl_setResponseMessage(msg: java.lang.String) : Void
Parameters
msg
&nbsp;
public impl_setToRead(bytes: Long) : Void
Parameters
bytes
&nbsp;
public impl_setToWrite(bytes: Long) : Void
Parameters
bytes
&nbsp;
public impl_setWriting() : Void
&nbsp;
public impl_setWritten(bytes: Long) : Void
Parameters
bytes
&nbsp;
public setHeader(name: java.lang.String, value: java.lang.String) : Void

Set the specified header and value as HTTP header on the outgoing HTTP request.

Set the specified header and value as HTTP header on the outgoing HTTP request. Existing headers of the same name, if any, are overwritten. Some commonly-used header names and values are defined in HttpHeader

Parameters
name
the HTTP header name
value
the HTTP header value
&nbsp;
public start() : Void

Starts a HTTP operation.

Starts a HTTP operation. Queues this request so that it can be processed. See the overview for how the operation can progress.

&nbsp;
public stop() : Void

Cancel this request's HTTP operation.

Cancel this request's HTTP operation. If the request is queued or executing, calling this function will subsequently cause cause the done variable to change value to true.

&nbsp;

Inherited Functions

javafx.async.Task

public impl_setCauseOfFailure(cause: java.lang.Throwable) : Void
Parameters
cause
&nbsp;
public impl_setDone() : Void
&nbsp;
public impl_setStarted() : Void
&nbsp;
public impl_setStopped() : Void
&nbsp;
public abstract start() : Void

Initiates execution of this task.

Initiates execution of this task. Calling this function will either queue this task for future execution or start execution. The execution of the task happens on a thread other than the JavaFX event dispatch thread. The onStart function may not be called before this function returns. This function is expected to be called a maximum of once per instance of Task.

See Also:
onStart

Profile: common

&nbsp;
public abstract stop() : Void

Terminates execution of this task.

Terminates execution of this task. Calling this function will either remove this task from the execution queue or stop execution. Subsequent calls to this function have no effect. The onDone function will be called as a result of calling this function, if it is non-null. The onDone function may not be called before this function returns. This function is expected to be called a maximum of once per instance of Task.

See Also:
stopped, onDone

Profile: common

&nbsp;



Spec-Zone.ru - all specs in one place