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 |
||||
public | GET | String |
HTTP GET method value. HTTP GET method value. Can be assigned to method |
||||
public | POST | String |
HTTP POST method value. HTTP POST method value. Can be assigned to method |
||||
public | PUT | String |
HTTP PUT method value. HTTP PUT method value. Can be assigned to method |
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 |
|||
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
See Also:
|
|
public-read protected | doneRead | Boolean | subclass | subclass | false |
Indicates if reading of response content from location has finished. |
|
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 |
|
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 |
|
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 |
|
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, unless sink is specified. The calling of onInput indicates that this variable contains a valid input stream to read. For the transfer of large amounts of data, use sink. null
See Also:
|
|
public | location | String | null |
Target location for this HttpRequest. Target location for this HttpRequest. URL format. null |
|||
public | method | String | GET |
Method to use for this request. |
|||
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 |
|||
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
Callback that is invoked once to indicate that an
|
|||
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.
This function is not called if sink is specified.
The provided |
|||
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 when method contains POST or PUT.
This function is not called if source is specified.
To keep the application from blocking, the data is first accumulated
in memory and sent after an application closes the
|
|||
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 |
|||
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 |
|||
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
See Also:
|
|||
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 or about to be transferred from source 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. Contains data to be written to location during HTTP operations where method contains POST or PUT. The calling of onOutput indicates that this variable contains a valid output stream to write to. Closing this output stream will initiate the transfer of its data to location. This output stream is ignored if source is specified. For the transfer of large amounts of data, use source. null
See Also:
|
|
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 |
|
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 |
|
public-init protected | sink | OutputStream | subclass | null |
Sink for response content for this request. Sink for response content for this request. The use of input works well for reading small amounts of data. sink is provided to allow the reading of large amounts of data from location without compromising an application's user interface responsiveness or requiring all of the data to be in memory at once. The alternative is to read all of the data transferred from input. This is typically done on the JavaFX event dispatch thread which may hinder the processing of application events. If this output stream is specified, input is ignored. Methods of this output stream are called from a thread other than the JavaFX event dispatch thread as data is available from location. No JavaFX code should be called from the methods of this output stream. Data is read from location and written to this stream until EOF is reached (-1 is returned) or an exception is encountered. In either case, the stream is subsequently closed. The toread and read variables are updated as data is transferred.null
See Also:
|
||
public-init protected | source | InputStream | subclass | null |
Source of data to be written to location during HTTP operations where method contains POST or PUT. Source of data to be written to location during HTTP operations where method contains POST or PUT. The use of output works well for writing small amounts of data. source is provided to allow the writing of large amounts of data to location without compromising an application's user interface responsiveness or requiring all of the data to be in memory at once. The alternative is to write all of the data to be transferred to output. This is typically done on the JavaFX event dispatch thread which may hinder the processing of application events. If this input stream is specified, output is ignored. Methods of this input stream are called from a thread other than the JavaFX event dispatch thread as data is needed to write to location. No JavaFX code should be called from the methods of this input stream. Data is read from this stream and written to location until EOF is reached (-1 is returned) or an exception is encountered. In either case, the stream is subsequently closed. The towrite and written variables are updated as data is transferred.null
See Also:
|
||
public-read protected | toread | Long | subclass | subclass | 0 |
Number of bytes expected to be read from input. |
|
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
See Also:
Profile: common |
|
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 Profile: common |
|
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
See Also:
Profile: common |
|
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:
Profile: common |
|
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:
Profile: common |
|||
public | onStart | function():Void | null |
Callback that is invoked once to indicate that the task is about to start execution. |
|||
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. A value between zero and one indicates 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:
Profile: common |
|||
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:
Profile: common |
|
public-read protected | started | Boolean | subclass | subclass | false |
Indicates if this task has started. |
|
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
See Also:
Profile: common |
|
public-read protected | succeeded | Boolean | subclass | subclass | false |
Indicates if this task has successfully completed. |
Function Summary
- public getResponseHeaderNames() : java.lang.String[]
-
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
- String[]
- 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.
- 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
- 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
- public start() : Void
- 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
.
Inherited Functions
javafx.async.Task
- 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:
onStartProfile: common
- 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.
Profile: common