URLFetchAsynchronous

As of Version 11, URLFetchAsynchronous has been superseded by URLSubmit.

URLFetchAsynchronous[url,func]

performs a connection in the background, calling func when an event is raised.

Details and Options

  • Types of events that may be raised:
  • "data"returns a list of bytes and indicates that the connection has completed
    "progress"returns information about the current connection of the form {dlnow,dltotal,ulnow,ultotal}
    "error"indicates that an error occurred while attempting to connect to a URL
    "headers"headers received from the web server
    "cookies"a list of all known cookies
    "statuscode"the status code returned by the server
  • The following options can be given:
  • Method"GET"method to use for request
    "Parameters" {}parameters to be sent for the request
    "Body"""contents of message body to be sent
    "MultipartElements"{}list of multipart data elements to send
    "Username" ""username to use for the request
    "Password" ""password to use for the request
    "Headers" {}headers to be manually sent to the HTTP server
    "Cookies" Automaticcookies to pass to the server
    "StoreCookies" Truewhether to store received cookies
    "VerifyPeer" Trueverify authenticity using SSL certificates
    "UserAgent" Automaticuser agent string to send
    "ReadTimeout" 0time to allow for uploading or downloading data
    "ConnectTimeout" 0time to allow for connecting to the server
    "Progress" Falsewhether to raise a "progress" event
    "Transfer" Automaticif Automatic, the "data" event returns once and returns all the data downloaded; if "Chunks", the "data" event is raised multiple times with the data downloaded since the last event was raised
    "UserData" Noneany expression passed to this option will be stored for use of the AsynchronousTaskObject inside the event function; the data can be found by checking the options of AsynchronousTaskObject passed to the event function
    "FollowRedirects"Truewhether to follow redirects
  • Allowed times are by default given in seconds.
  • Multipart elements must be of the form {"name","mimetype"}->val, where val is a string or a list of bytes.
  • When an event is raised, the event function passed to URLFetchAsynchronous will be executed. The event functions will be passed three arguments, the AsynchronousTaskObject, the event name, and the data received from the event. Event functions are the only method for handling data received from URLFetchAsynchronous.

Examples

open allclose all

Basic Examples  (3)

This opens a dialog when the download has finished:

Store headers and cookies:

Use the status code and error event to determine the availability of URLs:

Options  (16)

"Method"  (1)

"Method" can be used to specify the HTTP method used by the connection:

"Parameters"  (1)

Specify the parameters that should be sent to the server:

"VerifyPeer"  (1)

Verify that the SSL certificate used by the server is valid:

"Username"  (1)

Specify the username that should be sent to the server:

"Password"  (1)

Specify the password that should be sent to the server:

"UserAgent"  (1)

Specify the user agent that should be sent to the server:

"Cookies"  (1)

Manually control the cookies used by URLFetchAsynchronous:

"StoreCookies"  (1)

If False, "StoreCookies" will not place any new cookies found while connecting to the site in the global cookie share:

"Headers"  (1)

Specify headers to be sent to the server:

"BodyData"  (1)

Specify the message body that should be sent when connecting to the server:

"MultipartData"  (1)

Specify the contents of a multipart message body:

"ReadTimeout"  (1)

Specify the maximum allotted time in seconds to finish downloading data from the server:

"ConnectTimeout"  (1)

Specify the maximum allotted time in seconds to establish a connection to the server:

"Progress"  (1)

If True, the "progress" event will be raised, returning information downloaded and uploaded about in-progress downloads:

"Transfer"  (1)

If "Transfer" is set to "Chunks", data will be returned as soon as it is available from the server, instead of waiting for the entire connection to finish:

"UserData"  (1)

"UserData" is any expression containing information to be made available when an event is called:

Properties & Relations  (1)

Use URLSaveAsynchronous to store output in a file:

Wolfram Research (2012), URLFetchAsynchronous, Wolfram Language function, https://reference.wolfram.com/language/ref/URLFetchAsynchronous.html.

Text

Wolfram Research (2012), URLFetchAsynchronous, Wolfram Language function, https://reference.wolfram.com/language/ref/URLFetchAsynchronous.html.

CMS

Wolfram Language. 2012. "URLFetchAsynchronous." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/URLFetchAsynchronous.html.

APA

Wolfram Language. (2012). URLFetchAsynchronous. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/URLFetchAsynchronous.html

BibTeX

@misc{reference.wolfram_2024_urlfetchasynchronous, author="Wolfram Research", title="{URLFetchAsynchronous}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/URLFetchAsynchronous.html}", note=[Accessed: 18-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_urlfetchasynchronous, organization={Wolfram Research}, title={URLFetchAsynchronous}, year={2012}, url={https://reference.wolfram.com/language/ref/URLFetchAsynchronous.html}, note=[Accessed: 18-November-2024 ]}