Getting and Setting Information About a URL


Mac OS X header: Carbon/Carbon.h
Mac OS 9 header: URLAccess.h


Getting and Setting Information About a URL Functions
URLGetPropertySize Determines the size of a URL property.
URLGetProperty Obtains the value of a URL property.
URLSetProperty Sets the value of a URL property.


URLGetPropertySize

Carbon status: Supported

Determines the size of a URL property.

OSStatus URLGetPropertySize (
    URLReference urlRef, 
    const char *property, 
    Size *propertySize
);
Parameter descriptions
urlRef

A reference to the URL whose property size you want to determine.

property

A pointer to a C string representing the name of the property value whose size you want to determine. For a description of property name constants, see “Universal URL Property Name Constants” and “HTTP and HTTPS URL Property Name Constants”.

propertySize

On return, a pointer to the size (in bytes) of the specified property value. If the size is not available, URLGetPropertySize passes back -1 in this parameter and returns the result code kURLPropertyNotYetKnownError.

function result

A result code.

Discussion

The URLGetProperty function obtains the size of the property value identified by the property name constant passed in the property parameter. For a description of property name constants and data types of the corresponding property values, see “Universal URL Property Name Constants” and “HTTP and HTTPS URL Property Name Constants”.

You should call the URLGetPropertySize function before calling the function URLGetProperty to determine the size of the buffer containing the property value you wish to obtain. Pass the value passed back in the propertySize parameter in the bufferSize parameter of URLGetProperty.

Availability

Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.


URLGetProperty

Carbon status: Supported

Obtains the value of a URL property.

OSStatus URLGetProperty (
    URLReference urlRef, 
    const char *property, 
    void *propertyBuffer, 
    Size bufferSize
);
Parameter descriptions
urlRef

A reference to the URL whose property value you want to determine.

property

A pointer to a C string representing the name of the property value you want to determine. For a description of property name constants and their corresponding data types, see “Universal URL Property Name Constants” and “HTTP and HTTPS URL Property Name Constants”.

propertyBuffer

A pointer to a buffer containing the property value you want to obtain. You must also pass the correct data type of the property value you wish to obtain. Before calling URLGetProperty, allocate enough memory in this buffer to contain the property value you wish to obtain. On return, a pointer to a buffer containing the property value. If you do not allocate enough memory for the buffer, URLGetProperty does not pass back the property value in this parameter and returns the result code kURLPropertyBufferTooSmallError.

bufferSize

The size (in bytes) of the buffer pointed to by propertyBuffer. To determine the buffer size, call the function URLGetPropertySize. If the buffer size is too small, URLGetProperty returns the result code kURLPropertyBufferTooSmallError and does not pass back the property value in the propertyBuffer parameter.

function result

A result code. The result code kURLPropertyBufferTooSmallError indicates that you did not allocate enough memory for the buffer in the propertyBuffer parameter. The result code kURLPropertyNotYetKnownError indicates that the value of the property is not yet available.

Discussion

The URLGetProperty function obtains the value of a URL property identified by the property name constant specified in the property parameter.

Availability

Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.


URLSetProperty

Carbon status: Supported

Sets the value of a URL property.

OSStatus URLSetProperty (
    URLReference urlRef, 
    const char *property, 
    void *propertyBuffer, 
    Size bufferSize
);
Parameter descriptions
urlRef

A reference to the URL whose property value you want to set.

property

A pointer to a C string representing the name of the property value you want to set. You can only set property values identified by the constants kURLPassword, kURLUserName, kURLHTTPRequestMethod, kURLHTTPRequestHeader, kURLHTTPRequestBody, and kURLHTTPUserAgent. For a description of these property name constants and their corresponding data types, see “Universal URL Property Name Constants” and “HTTP and HTTPS URL Property Name Constants”.

propertyBuffer

A pointer to a buffer containing the data you would like the property to be set to. The data must be of the correct type.

bufferSize

The size (in bytes) of the data you want to set.

function result

A result code. The result code kURLUnsettablePropertyError indicates that a property value cannot be set.

Discussion

The URLSetProperty function enables you to set those property values identified by the following constants: kURLPassword, kURLUserName, kURLPassword, kURLHTTPRequestMethod, kURLHTTPRequestHeader, kURLHTTPRequestBody, and kURLHTTPUserAgent. For a description of these property name constants and their corresponding data types, see “Universal URL Property Name Constants” and “HTTP and HTTPS URL Property Name Constants”.

You may wish to call URLSetProperty before calling the function URLDownload or URLUpload to set a URL property before a data transfer operation.

Availability

Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.


© 2001 Apple Computer, Inc. (Last Updated July 21, 2001)