diff options
author | RJ Ryan <rryan@mixxx.org> | 2015-12-27 22:54:34 -0500 |
---|---|---|
committer | RJ Ryan <rryan@mixxx.org> | 2015-12-27 22:54:34 -0500 |
commit | eac04f98681da0ffc8d29cfa38dd2201ce106eca (patch) | |
tree | 77f5f4550e07e373b32e9b3581cc484e47fdd5fb /src | |
parent | dbc3751b5457b91e9993940a2713563dbbc96a26 (diff) |
Add debug printing for AcoustIdClient.
This will help us debug user problems and only runs if the user
initiates a tag fetch so it won't be too spammy.
Diffstat (limited to 'src')
-rw-r--r-- | src/musicbrainz/acoustidclient.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/musicbrainz/acoustidclient.cpp b/src/musicbrainz/acoustidclient.cpp index 91612f3981..19936b6573 100644 --- a/src/musicbrainz/acoustidclient.cpp +++ b/src/musicbrainz/acoustidclient.cpp @@ -10,7 +10,9 @@ #include <QCoreApplication> #include <QNetworkReply> #include <QXmlStreamReader> +#include <QTextStream> #include <QUrl> +#include <QtDebug> #include "acoustidclient.h" #include "gzip.h" @@ -40,13 +42,17 @@ void AcoustidClient::start(int id, const QString& fingerprint, int duration) { url.addQueryItem("duration", QString::number(duration)); url.addQueryItem("meta", "recordingids"); url.addQueryItem("fingerprint", fingerprint); + QByteArray body = url.encodedQuery(); QNetworkRequest req(QUrl::fromEncoded(ACOUSTID_URL.toAscii())); req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); req.setRawHeader("Content-Encoding", "gzip"); req.setRawHeader("User-Agent", CLIENT_NAME.toAscii()); - QNetworkReply* reply = m_network.post(req, gzipCompress(url.encodedQuery())); + qDebug() << "AcoustIdClient POST request:" << ACOUSTID_URL + << "body:" << body; + + QNetworkReply* reply = m_network.post(req, gzipCompress(body)); connect(reply, SIGNAL(finished()), SLOT(requestFinished())); m_requests[reply] = id; @@ -75,14 +81,22 @@ void AcoustidClient::requestFinished() { int id = m_requests.take(reply); - if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) { + int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + if (status != 200) { + QTextStream body(reply); + qDebug() << "AcoustIdClient POST reply status:" << status << "body:" << body.readAll(); emit(networkError( reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), "AcoustID")); return; } - QXmlStreamReader reader(reply); + + QTextStream textReader(reply); + QString body = textReader.readAll(); + qDebug() << "AcoustIdClient POST reply status:" << status << "body:" << body; + + QXmlStreamReader reader(body); QString ID; while (!reader.atEnd()) { if (reader.readNext() == QXmlStreamReader::StartElement |