| |
| DWORD WINAPI HttpAddQueuedFile( |
| |
HQUEUE hQueue, |
|
| |
DWORD dwQueueMode, |
|
| |
LPCTSTR lpszLocalFile, |
|
| |
LPCTSTR lpszRemoteFile, |
|
| |
DWORD dwOptions, |
|
| |
UINT nTimeout |
|
| ); |
The HttpAddQueuedFile function adds a new file to the queue
with additional transfer options.
Parameters
- hQueue
- A handle to a file transfer queue.
- dwQueueMode
- An integer value which specifies if the file should be
downloaded from the server or uploaded to the server. This parameter
must be one of the following options and cannot have a value of
zero.
| Constant |
Description |
| HTTP_QUEUE_DOWNLOAD |
The file should be queued for downloading from the server to
the local system. |
| HTTP_QUEUE_UPLOAD |
The file should be queued for uploading from the local
system to the server. |
- lpszLocalFile
- A null-terminated string which specifies the name
of the local file to be queued for transfer. This parameter cannot
be NULL or point to an empty string. If the file is being queued for
an upload, the file must exist on the local system or the function
will fail. If the file is being downloaded, it will be created or
replaced on the local system.
- lpszRemoteFile
- A null-terminated string which specifies the
URL to the location of the file on the server. The URL must follow
the conventions for the File Transfer Protocol and may specify
either a standard or secure connection, alternate port number,
username, password and optional working directory.
- dwOptions
- An unsigned integer value which specifies one or more options. This
parameter is constructed by using a bitwise operator and can be any
of the options used with the HttpConnect function.
If this value is zero, the default options for the queue will be
used. The most common options are:
| Value |
Description |
| HTTP_OPTION_DEFAULT |
Default options should be used for the queued transfer.
All standard headers will be included with the request and
redirected resources will return an error, allowing the
application to determine if it should request the resource from
the new location or inform the user the resource location has
changed. |
| HTTP_OPTION_REDIRECT |
This option specifies the client should automatically
handle resource redirection. If the server indicates that the
requested resource has moved to a new location, the client will
close the current connection and request the resource from the
new location. Note that it is possible that the redirected
resource will be located on a different server. |
| HTTP_OPTION_PROXY |
This option specifies the client should use the
default proxy configuration for the local system. If the system
is configured to use a proxy server, then the connection will
be automatically established through that proxy; otherwise, a
direct connection to the server is established. The local proxy
configuration can be changed in the system settings or control
panel. |
| HTTP_OPTION_HTTP2 |
This option specifies the client should attempt a HTTP/2
connection with the server. If a connection cannot be established
using HTTP/2 the client will attempt to connect using an earlier
version of the protocol. |
| HTTP_OPTION_SECURE |
This option specifies the client should attempt to
establish a secure connection with the server. Note that the
server must support secure connections using the TLS protocol.
The client will default to using TLS 1.2 or later for secure
connections. |
- nTimeout
- The number of seconds to wait for a response from the server
before failing the file transfer. If this value is zero, the default
timeout period for the queue will be used.
Return Value
If the function succeeds, the return value is a unique identifier
which corresponds to the queued file. If the function fails, the return
value is zero. To get extended error information, call HttpGetLastError.
Remarks
This function will add a file to the current transfer queue. If
successful, the value returned is a unique integer which identifies
that file in the queue. To obtain information about the queued file,
you can call the HttpGetQueuedFile function and
provide this return value as the dwFileId parameter. To
remove a file from the queue, use the HttpRemoveQueuedFile
function.
Files can only be added to the queue when in an idle or
paused state. If you attempt to add a file to the queue while the
queue manager is transferring files, the function will fail. To
determine the current state of the queue, call the HttpGetQueueStatus
function
There are no fixed limits to the number of files which can be
queued for transfer. To release the memory allocated for the queue,
call the HttpClearQueue function. To determine the
current status of the queue, including how many file transfers have
been queued and how many are pending completion, call the
HttpGetQueueStatus function.
If the local file path includes environment variables enclosed in
percentage (%) symbols, those values will be expanded based on the
environment variables defined for the current user using the
ExpandEnvironmentStrings function in the Windows API.
Note that environment variable names are not case-sensitive.
This function will not immediately begin the process of uploading
or downloading the file. It will only add the transfer request to the
current queue. The file transfers are managed by a background worker
thread which is created when the HttpStartQueue
function is called.
The HttpAddQueuedFileEx function is an extended
version of this function with additional parameters to specify a
hostname, port number, user name and password. Because most file
uploads require authentication, using the extended function may be
preferred to composing a URL which includes the account credentials.
Example
HQUEUE hQueue = HttpCreateQueue(INFINITE, HTTP_TIMEOUT, HTTP_OPTION_DEFAULT);
if (hQueue == INVALID_QUEUE)
return;
DWORD dwFileId = HttpAddQueuedFile(
hQueue,
lpszLocalFile,
lpszRemoteFile,
HTTP_OPTION_DEFAULT,
HTTP_TIMEOUT);
if (dwFileId != 0)
{
HTTPQUEUEDFILE queuedFile;
if (HttpGetQueuedFile(hQueue, dwFileId, &queuedFile))
{
switch (queuedFile.dwMode)
{
case HTTP_QUEUE_DOWNLOAD:
_tprintf(_T("%u: Download \"%s\" to \"%s\"\n"),
dwFileId,
queuedFile.szRemoteFile,
queuedFile.szLocalFile);
break;
case HTTP_QUEUE_UPLOAD:
_tprintf(_T("%u: Upload \"%s\" to \"%s\"\n"),
dwFileId,
queuedFile.szLocalFile,
queuedFile.szRemoteFile);
break;
}
}
}
if (HttpStartQueue(hQueue, HTTP_QUEUE_ALL, 0, NULL, 0))
{
HttpWaitForQueue(hQueue, INFINITE, &dwElapsed, &dwError);
HttpStopQueue(hQueue);
}
HttpDeleteQueue(hQueue);
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtpv12.lib
Unicode: Implemented as Unicode and ANSI versions
See Also
|
|