2010-08-19 11:03:50 +00:00
|
|
|
//unfortunately, have to wrap the docs in a C comment for doxygen
|
2011-09-08 01:17:58 +00:00
|
|
|
// vim:tw=74:formatoptions-=l
|
2010-08-19 11:03:50 +00:00
|
|
|
/**
|
|
|
|
\page qw_download_spec QW Download Specification
|
|
|
|
|
2007-03-21 11:18:12 +00:00
|
|
|
client has 'h' flag in "*cap" info string
|
|
|
|
|
|
|
|
format of svc_download message:
|
2010-08-19 11:03:50 +00:00
|
|
|
\verbatim
|
2007-03-21 11:23:11 +00:00
|
|
|
<size (short)> <percent (byte)> ([url (string)] [newname (string)] | [data])
|
2010-08-19 11:03:50 +00:00
|
|
|
\endverbatim
|
2007-03-21 11:18:12 +00:00
|
|
|
|
|
|
|
size and percent are always present.
|
|
|
|
|
|
|
|
url is present only for http redirects.
|
|
|
|
|
2007-03-21 11:23:11 +00:00
|
|
|
data is present only when size is > 0 (ie, normal downloading)
|
|
|
|
|
2007-03-21 11:18:12 +00:00
|
|
|
newname is present for all http redirects (but may be the empty string) or if
|
|
|
|
the file to download has a different name to what what requested. This is so
|
|
|
|
the client saves the downloaded file with the correct name (in QF, this is
|
|
|
|
currently used for gzipped transfers, but there are plans to enable whole pak
|
|
|
|
downloads (similar to RTCW and ET)).
|
|
|
|
|
|
|
|
size is the number of data bytes in the message (if >= 0) or a special flag:
|
2010-08-19 11:03:50 +00:00
|
|
|
\li -1 file not found. download aborted
|
|
|
|
\li -2 download filename is not what was requested (in QF, this is because
|
2007-03-21 11:18:12 +00:00
|
|
|
the file has been gzipped and has the .gz extension). In this case,
|
|
|
|
newname is in the message. Currently, QF checks newname to ensure the
|
|
|
|
only modification is the addition of an extension.
|
2010-08-19 11:03:50 +00:00
|
|
|
\li -3 http redirect. url is always present and is the full url to download.
|
2007-03-21 11:18:12 +00:00
|
|
|
If the download name is the same as the requested name, newname will
|
|
|
|
be the empty string (""), otherwise it contains the new name of the
|
|
|
|
file. See -2.
|
|
|
|
|
2011-07-10 10:12:07 +00:00
|
|
|
QF \#defines for the above values:
|
2010-08-19 11:03:50 +00:00
|
|
|
\verbatim
|
2007-03-21 11:18:12 +00:00
|
|
|
#define DL_NOFILE -1
|
|
|
|
#define DL_RENAME -2
|
|
|
|
#define DL_HTTP -3
|
2010-08-19 11:03:50 +00:00
|
|
|
\endverbatim
|
2007-03-21 11:18:12 +00:00
|
|
|
|
|
|
|
Pseudo-code representing client side handling of svc_download
|
2010-08-19 11:03:50 +00:00
|
|
|
\verbatim
|
2007-03-21 11:18:12 +00:00
|
|
|
CL_ParseDownload
|
|
|
|
{
|
|
|
|
size = MSG_ReadShort (net_message);
|
|
|
|
percent = MSG_ReadByte (net_message);
|
|
|
|
if (size == DL_NOFILE) {
|
|
|
|
abort download
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (size == DL_RENAME) {
|
|
|
|
newname = MSG_ReadString (net_message);
|
|
|
|
if (newname is bad) {
|
|
|
|
abort download
|
|
|
|
return
|
|
|
|
}
|
|
|
|
rename file
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (size == DL_HTTP) {
|
|
|
|
url = MSG_ReadString (net_message);
|
|
|
|
newname = MSG_ReadString (net_message);
|
|
|
|
if (newname != "") {
|
|
|
|
if (newname is bad) {
|
|
|
|
abort download
|
|
|
|
return
|
|
|
|
}
|
|
|
|
rename file
|
|
|
|
}
|
|
|
|
start http transfer
|
|
|
|
return
|
|
|
|
}
|
|
|
|
normal download processing
|
|
|
|
}
|
2010-08-19 11:03:50 +00:00
|
|
|
\endverbatim
|
2007-03-21 11:18:12 +00:00
|
|
|
|
2010-08-19 11:03:50 +00:00
|
|
|
\note While the QF quakeworld server simply appends the requested file's path
|
|
|
|
to the given url base, with the addition of a '/' (eg, "maps/foo.map" to
|
2007-03-21 11:18:12 +00:00
|
|
|
"http://server/downloads", giving "http://server/downloads/maps/foo.map"), so
|
|
|
|
long as it is reasonable for the client to not rename the download file, there
|
|
|
|
is no requirement for the full url to match the requested name in any manner,
|
|
|
|
and newname can be left as empty (""). However, if the client must rename the
|
|
|
|
file, set newname to the new name. The extension checking is done as a
|
|
|
|
security measure.
|
|
|
|
|
2010-08-19 11:03:50 +00:00
|
|
|
\note Currently, the only reason QF renames a download is if it found eg
|
2007-03-21 11:18:12 +00:00
|
|
|
"maps/foo.map.gz" instead of "maps/foo.map" (2:1 to 3:1 compression on maps is
|
|
|
|
nice). This is the basis of the extension checking the QF clients do.
|
|
|
|
|
2010-08-19 11:03:50 +00:00
|
|
|
\todo [this has no bearing on the protocol itself]
|
2007-03-21 11:18:12 +00:00
|
|
|
One good reason for the name being quite different is when the requested file
|
|
|
|
is part of a pak file (and downloading the pak file is permitted), the entire
|
|
|
|
pak file can be sent instead. QF does not yet do this, but it should be easy
|
|
|
|
enough to implement: if file_from_pak (from FOpenFile) is set, and pak file
|
|
|
|
downloading is permitted, do a rename (-2 for non-http, set newname in http)
|
|
|
|
and send that instead. The client can check for a ".pak" extension in the
|
|
|
|
rename, permit it, and then cause a rescan of the game directory in order to
|
|
|
|
pick up the new pak file.
|
2010-08-19 11:03:50 +00:00
|
|
|
*/
|