Skip to content

Commit

Permalink
Fixed|Updater: Downloading files from SourceForge
Browse files Browse the repository at this point in the history
Apparently SourceForge now requires that the User-Agent is specified
in the GET request.
  • Loading branch information
skyjake committed Nov 25, 2013
1 parent 7867443 commit 9346404
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doomsday/client/include/network/net_main.h
Expand Up @@ -271,4 +271,6 @@ void Net_RecordToServerInfo(de::Record const &rec, serverinfo_t *info);
} // extern "C"
#endif

de::String Net_UserAgent();

#endif /* LIBDENG_NETWORK_H */
2 changes: 1 addition & 1 deletion doomsday/client/src/network/masterserver.cpp
Expand Up @@ -130,7 +130,7 @@ void MasterWorker::nextJob()

// Let's form an HTTP request.
QNetworkRequest req(masterUrl(d->currentAction == REQUEST_SERVERS? "?list" : 0));
req.setRawHeader("User-Agent", "Doomsday Engine " DOOMSDAY_VERSION_TEXT);
req.setRawHeader("User-Agent", Net_UserAgent().toLatin1());

#ifdef __SERVER__
if(d->currentAction == ANNOUNCE)
Expand Down
7 changes: 7 additions & 0 deletions doomsday/client/src/network/net_main.cpp
Expand Up @@ -58,6 +58,7 @@
#include "world/p_players.h"

#include <de/Value>
#include <de/Version>

// MACROS ------------------------------------------------------------------

Expand Down Expand Up @@ -1469,3 +1470,9 @@ boolean Net_StringToServerInfo(const char *valuePair, serverinfo_t *info)
}
return true;
}

de::String Net_UserAgent()
{
return QString(DOOMSDAY_NICENAME " " DOOMSDAY_VERSION_TEXT) +
" (" + de::Version().operatingSystem() + ")";
}
6 changes: 5 additions & 1 deletion doomsday/client/src/updater/downloaddialog.cpp
Expand Up @@ -28,6 +28,7 @@
#include "SignalAction"
#include "ui/clientwindow.h"
#include "dd_version.h"
#include "network/net_main.h"

#include <QNetworkAccessManager>
#include <QNetworkReply>
Expand Down Expand Up @@ -113,7 +114,10 @@ DENG2_PIMPL(DownloadDialog)
QDir::current().mkpath(UpdaterSettings().downloadPath()); // may not exist
savedFilePath = UpdaterSettings().downloadPath() / path.fileName();

reply = network->get(QNetworkRequest(uri));
QNetworkRequest request(uri);
request.setRawHeader("User-Agent", Net_UserAgent().toLatin1());
reply = network->get(request);

QObject::connect(reply, SIGNAL(metaDataChanged()), thisPublic, SLOT(replyMetaDataChanged()));
QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)), thisPublic, SLOT(progress(qint64,qint64)));

Expand Down

0 comments on commit 9346404

Please sign in to comment.