4/5/99 |
Added URLDownloadWithSigner |
10/16/98 |
Added URLSimpleDownload and URLSimpleUpload |
5/28/98 |
System Event callback, pass back URLReference from URLUpload and URLDownload |
5/6/98 |
Added uploading |
3/20/1997 |
Added |
3/12/1997 |
Added |
3/10/1997 |
States are no longer
flags. |
3/9/1997 |
Remodeled states and events. Added
|
3/4/1997 |
Clarification of what happens to the filespec passed in
|
2/28/1997 |
|
2/27/1997 |
Changed post processing flags in |
2/26/1997 |
|
2/24/1997 |
More errors codes. Changed
open flags. Added |
2/21/1997 |
Add |
2/20/1997 |
|
2/12/1997 |
first posted |
Warning and Disclaimer: URL Access calls are implemented using Power PC-only features, and will fail if they are run from a 68K context. This is true whether they are invoked directly from a 68K application, or from a library ultimately linked to a 68K application.
This call allows the client application to download a file without any additional work. It does not allow the client to control the progress of the download in any way. The progressive calls of this API should be used if greater control is needed.URLDownload downloads a given URL to a given FSSpec. This call is synchronous. It will not return until the download is complete. It will however yield to other threads. We recommend that this call is made from a thread other than the main thread of your application. If not, other processes will not get time until the call is complete.
The client application may wish to have a progress bar dialog displayed during the download. Because the dialog is modal, there may only be one progress bar displayed at a time. If this routine is called with the
kURLDisplayProgressFlag
set while a progress bar is already displayed, then the call will return with akURLProgressAlreadyDisplayedError
error.To specify the name of the resulting file or directory, pass a fully specified FSSpec. To use the original name, leave the FSSpec name field empty. If you specify a name that already exists on the system and do not specify the kURLReplaceExistingFlag, URLDownload will return with kURLDestinationExistsError. If the name is not specified, the destination exists, and the kURLReplaceExistingFlag is not set, a unique name will be created by appending a number to the original name.
To download a URL asynchronously, use the
URLOpen
call instead.
|
|
|
the target URL to be downloaded. |
|
the destination file or directory to download the data
to. If this is an existing file or directory and the
|
destinationHandle |
if you want to download the data into memory instead of a fileSpec, allocate a handle of at least one byte and pass it in here. |
|
options for the download. Flag values are:
|
|
If supplied, routine will be called to communicate system events to the calling application. If it is not supplied, the progress bar and authentication dialogs (if requested) will be non-movable modal. If supplies, dialogs will be movable modal. |
|
a user specified value which will be passed in to the system event callback. |
This call is very similar to URLSimpleDownload except that it takes a URLReference instead of a string.
|
|
|
the URLReference to be downloaded. Before calling URLDownload you should set any properties of the URLReference that need to be set. |
|
the destination file or directory to download the data
to. If this is an existing file or directory and the
|
destinationHandle |
if you want to download the data into memory instead of a fileSpec, allocate a handle of at least one byte and pass it in here. |
|
options for the download. Flag values are:
|
|
If supplied, routine will be called to communicate system events to the calling application. If it is not supplied, the progress bar and authentication dialogs (if requested) will be non-movable modal. If supplies, dialogs will be movable modal. |
|
a user specified value which will be passed in to the system event callback. |
This call is identical to URLDownload, except that it takes an additional parameter, a pointer to a SecSignerRef. Please see the documentation on Macintosh File Signing (the iSign architecture) for additional information.
|
|
|
the URLReference to be downloaded. Before calling URLDownloadWithSigner you should set any properties of the URLReference that need to be set. |
|
the destination file or directory to download the data
to. If this is an existing file or directory and the
|
destinationHandle |
if you want to download the data into memory instead of a fileSpec, allocate a handle of at least one byte and pass it in here. |
|
options for the download. Flag values are:
|
|
If supplied, routine will be called to communicate system events to the calling application. If it is not supplied, the progress bar and authentication dialogs (if requested) will be non-movable modal. If supplied, dialogs will be movable modal. |
|
a user specified value which will be passed in to the system event callback. |
signer |
a pointer to a SecSignerRef. If kURLExpandAndVerifyFlag is specified, the SecSignerRef will point to information about the signer, including the corresponding chain of digital certificates used to sign the file, when the call to URLDownloadWithSigner returns. This information can be retrieved by the iSign APIs. If the signer parameter is nil, no information about the signer is retrieved. |
This call allows the client application to upload a file or directory without any additional work. It does not allow control of the progress of the upload in any way. The progressive calls of this API should be used for more control. URLUpload only supports ftp URLs.URLUpload uploads the given FSSpec to the given URL. This call is synchronous. It will not return until the upload is complete. It will however, yield to other threads. We recommend that this call is made from a thread other than the main thread of your application. If not, other processes will not get time until the call is complete.
The client application may wish to have a progress bar dialog displayed during the download. There may only be one progress bar displayed at a time. If this routine is called with the
kURLDisplayProgressFlag
set while a progress bar is already displayed, then the call will return withkURLProgressAlreadyDisplayedError
.To specify the name of the resulting file or directory, pass a fully specified URL that does not end in '/'. This tells URL Access that the URL is fully specified as opposed to pointing to the destination directory only. To use the original name, pass in the path to the destination directory and terminate it with a '/'. If you specify a name that already exists on the server and do not specify the kURLReplaceExistingFlag, URLUpload will return with kURLDestinationExistsError. If the name is not specified, the destination exists, and the kURLReplaceExistingFlag is not set, a unique name will be created by appending a number to the original name.
To upload to a URL asynchronously, use the
URLOpen
call instead.
|
|
|
the destination URL. |
|
the source file spec. |
|
options for the upload. Flag values are:
|
|
If supplied, routine will be called to communicate system events to the calling application. If it is not supplied, the progress bar and authentication dialogs (if requested) will be non-movable modal. If supplies, dialogs will be movable modal. |
|
a user specified value which will be passed in to the system event callback. |
This call is very similar to URLSimpleDownload except that it takes a URLReference instead of a string.
|
|
|
the URLReference to be downloaded. Before calling URLDownload you should set any properties of the URLReference that need to be set. |
|
the source file spec. |
|
options for the upload. Flag values are:
|
|
If supplied, routine will be called to communicate system events to the calling application. If it is not supplied, the progress bar and authentication dialogs (if requested) will be non-movable modal. If supplies, dialogs will be movable modal. |
|
a user specified value which will be passed in to the system event callback. |
Create a reference to a URL for future use.
|
|
|
the URL this reference should point to. |
|
when the call returns, points to a valid URLReference. |
Disposes of a reference to a URL.
|
|
|
the reference to dispose of. |
Opens a URL for streaming, initiating a download or upload. This call is asynchronous and returns immediately.If the file parameter is provided for a download, then the data is automatically downloaded to the file spec. Otherwise, the client application must retrieve the data as it is downloaded. If you are downloading an entire directory, you must supply a file spec. You cannot retrieve the data yourself.
The file parameter must be provided for an upload, and the data is automatically uploaded from the file. If you are uploading an entire directory, you must provide a file spec for the directory. There is not way to provide the data yourself.
To get completion of the call, the client application needs to provide a notification callback routine or can poll status using the URLGetCurrentState call.
|
|
|
the URL reference to be opened. |
|
the destination/source file spec. If this parameter is nil and a file is being downloaded, the client application will be retrieving the downloaded data. Otherwise, the data will be downloaded to the destination file and the client application will not receive any data event (see notification ). This parameter must be specified to upload or download a directory. If this parameter is provided, the client application
does not have access to buffer states
and events, not to the
|
|
options for the transaction. See URLDownload and URLUpload for values. |
|
a notification proc ptr. This procedure is called to report events that have been registered through the eventRegister parameter. It may report downloading events such as starting of the download or completion, or indicate that a property has changed such as status string or last modification time. |
|
a bitmap indicating which events the client application wishes to be notified of. |
|
a user specified value which will be passed in to the notification routine. |
Aborts a URL download or upload started with the
URLOpen
call, terminating the
process.
|
|
|
indicates which URL download or upload should be aborted. |
Gets the amount of data available to retrieve with the
URLGetBuffer
call. Only
available for downloading files.
|
|
|
the URL reference to get the amount of data available from. |
|
a pointer to the size of the data buffer. On return, the buffer is set to the number of bytes available to retrieve. |
Gets a buffer from the URL download. The client should always release a buffer obtained through this call. The call returns the amount of data obtained. This routine may not return all the data available and the client application may need to call it multiple times to retrieve all the available data.The buffer returned must not be modified (it is read-only) or the system may crash.
This call allows data to be retrieved by the client application without copying data. The client however should release the buffer as soon as possible to avoid congestion at the lower system level.
Only available for downloading files.
|
|
|
the URL reference to get the buffer from. |
|
a pointer to a pointer to a memory buffer. On return, the buffer contains the downloaded data. |
|
a pointer to the length of the buffer. On return, bufferSize is set to the number of bytes in the buffer. |
Releases a buffer back to the URL stream. Only available for downloading files.
|
|
|
the URL reference to release the buffer to. |
|
the buffer to release. |
Properties provide information about the URL or the resource the URL points to. They may change during the download (from unknown to some value or from one value to another value). When this happends, a kURLPropertyChangedEvent will be issued.The following universal properties are defined and reserved:
Name |
Description |
Type |
* |
---|---|---|---|
|
the URL string. |
|
|
|
the total size of the resource data. For directories, this will be the total size of all files before expanding/compressing. |
|
|
|
the last time the data was modified. |
|
|
|
the MIME type of the data. |
|
|
|
the type of the file specified in |
|
|
|
the creator of the file specified in |
|
|
|
the character set of the data. |
|
|
|
the name of the resource currently being uploaded or downloaded. |
|
|
|
the host the resource is on. |
|
|
|
the type of authentication information that this
operation requires. The default value is
|
|
|
|
the user name used or to be used for authentication. If the username and password are not set and authentication is required by the server, an authentication dialog will be displayed. If the client requested no authentication dialog and the username and password are not set or are incorrect, a kURLAuthenticationError will be set/returned. |
|
|
|
the password to be used for authentication. See above for more info. |
|
|
|
a string indicating the current status of the stream for optional display. |
|
|
|
indicates whether the transaction is secure or not. |
|
|
|
the certificate provided by the remote server. Only valid for https. |
|
|
kURLNumItems |
the total number of items to be uploaded or downloaded. |
|
URLSetProperty
routine.
The following HTTP-specific properties are defined and reserved (these properties are only available when the URL scheme ishttp
orhttps
):
Name |
Description |
Type |
* |
---|---|---|---|
|
the HTTP method to be used in the request. |
|
X |
|
the HTTP request header. If this property is set, it must contain all needed headers for the request. |
|
|
|
the HTTP request body to be provided in the request. If
this property is set, but not the
|
|
|
|
the HTTP response header. |
|
URLSetProperty
routine.
To get properties defined asconst char*
, the client application should first call theURLGetPropertySize
routine to obtain the total size of the property.
Gets a property from the URL stream.
|
|
|
the URL reference to get the property from. |
|
the property to get. This parameter is a null terminated string to allow for extensibility. The previous properties are reserved. |
|
a buffer to put the property value into. |
|
the size of the supplied property buffer. |
Returns the size of a property if it is known at that point. Otherwise it will return -1. Some properties do not need to be queried for size such as resource size and modification date.
|
|
|
the URL reference to get the property size from. |
|
the property to get the size of. This parameter is a null terminated string to allow for extensibility. The previous properties are reserved. |
|
a pointer to the size of the property on return. |
Sets a property from the URL stream. Some properties may not be set such as size and URL string.To clear a property, it should be set with an empty string.
|
|
|
the URL reference to get the property from. |
|
the property to set. This parameter is a null terminated string to allow for extensibility. The previous properties are reserved. |
|
a buffer to read the property value from. |
|
the size of the supplied property buffer. |
Returns the current state of the URL stream. Possible states are:
|
|
|
the download has been initiated.The server has not been
reached yet. This state is only set after the
|
|
the client system is using the Domain Name Service (DNS) to resolve the name of the host. This state is only set after the kURLInitiatingState state. Also, this state is optional, since not all URLs will go through it (for example, a file:// URL). |
|
the client system is establishing a connection to the remote server. This state is only set after the kURLInitiatingState state, and if there is one, after the kURLLookingUpHostState state. This state is optional, since not all URLs will go through it (for example, a file:// URL). |
|
the resource has been found. This state is only set after
the |
|
the download of the resource has started. This state is
only set after the |
|
the download is being aborted. |
|
the download or an abort is now completed. The client application should now dispose of the url reference. |
|
an error has occured. The client application may retrieve
that error by calling the |
kURLUploadingState |
the upload has started. |
The following states are available if nofileSpec
parameter was provided in theURLOpen
call:
|
data is available to retrieve. |
|
the file downloading is complete. there is no more data available to retrieve. |
|
|
|
the URL reference to get the state from. |
|
the state of the stream. |
Retrieves the first non-trivial error encountered by the URL stream. This may include system errors as well as errors defined in this API.
|
|
|
the URL reference to get the error from. |
|
a pointer to the first non-trivial error encountered by the URL stream. |
The following errors are defined in these specifications and may also be returned by any of the calls defined (except URLDownload):
|
the URL reference that was passed in is invalid. |
kURLProgressAlreadyDisplayedError |
the client already has an upload or download running with progress displayed. |
kURLDestinationExistsError |
a destination name was specified that already exists and the client indicated not to replace existing. |
|
the URL that was passed in has an invalid format. |
|
the scheme of the URL is not supported. |
|
the server is currently busy. |
|
authentication with the server has failed. |
|
the property passed as a parameter is not defined. |
|
the buffer passed to get the property
is to small. Call |
|
this property cannot be set
(e.g. |
|
InternetConfig, which is required, is not available. |
|
the source file is empty. |
kURLInvalidCallError |
a call was made that does not apply to the current transaction (e.g. calling URLGetDataAvailable when an upload is being performed). |
|
this call was meant to be handled by an extension but the extension did not support it. |
kURLInvalidConfigurationError |
The user's configuration does not support performing the transaction (e.g. downloading an FTP directory with a proxy on). |
kURLAccessNotAvailableError |
URL Access is not available on this system. |
This section describes the callback routines that may be provided by the client application. There are two types of routines, one used for monitoring an operation when streaming is being used (Notification Callback), the other used to communicate system events to the client application when a synchronous call (URLUpload or URLDownload) is being used (System Event Callback).
The notification callback routine reports URL events that may be
usefull to the client application for displaying progress information
or retrieving the downloaded data (when no destination
has been specified in the URLOpen
call). The client application may register for the notification of
only the events it needs (by providing the eventRegister
parameter in the URLOpen
call).
For example:
kURLPropertyChangedEvent
.kURLPercentEvent
.This routine is called to notify the client application of events it has registered for or to regularly provide download data size. Possible events are:
|
if the client application has registered for this event, the notification callback routine will be called every time a new percent of data has been downloaded or uploaded. If the total size of the file resource is unknown, then this event will not be reported. |
|
if the client application has registered for this event, the notification callback routine will be called periodically (every 250ms). |
|
this event occurs when the property
indicated by the
|
kURLSystemEvent |
this event is used to pass an EventRecord to the calling app for processing. |
|
indicates that the corresponding state is now active. |
|
indicates that the corresponding state is now active. |
|
indicates that the corresponding state is now active. |
kURLUploadingEvent |
indicates that the corresponsing state is now active |
|
indicates that the corresponding state is now active. |
|
indicates that the corresponding state is now active. |
|
indicates that the corresponding state is now active. |
The following events are available if nofile
parameter was provided in theURLOpen
call and a download is being performed:
|
indicates that the corresponding state is now active. |
|
indicates that the corresponding state is now active. |
This routine should always return noErr
(reserved for future use).
|
|
|
the user context that was passed in to URLOpen. |
|
indicates which event is being reported. |
|
A structure containing event-relevant information:
|
The system event callback is used to communicate system events to the client application when progress or authentication is being displayed. If you request progress or authentication UI and do not provide this parameter, the dialogs will be modal.
When this routine is called, your application should process the event as you would normally.
|
|
|
the user context that was passed in to URLDownload or URLUpload. |
|
a reference to the URL. |
|
the System event to be processed. |
This API may be extended to support additional schemes or to overide existing schemes. This section describes how a third-party can implment an extension. In this section "API implementation" refers to the implmentation of the API described in these specifications.
An extension is implemented as a shared library with a 'sbwx' creator type. It should be placed in the extension folder. When the API implementation shared library is initialized, it scans the extension folder for creator type 'sbwx' libraries. If any is found, it then looks in the resource fork of these libraries for a 'STR#' (ID -20902) resource containing the schemes that the extension supports. If a scheme is already supported by the API implementation, the extension overides it.
An extension should implement every routine defined in these specifications except URLDownload and URLUpload. Their behavior should fully comply to these specifications. In particular, it should support all universal properties and all events.
An extension may not use a routine, return value, parameter, property or event with a different intent than the one described in these specifications.
An extension may support additional properties and events. To take advantage of them, a client application will need to know that the extension is available (by scanning the extensions folder for instance) and know these properties' and events' behaviors. It is recommended that property names include the third party's name.