...
 
Commits (4)
......@@ -172,8 +172,10 @@ void FurAffinityClient::uploadSubmissionFile(qlonglong uploadId)
{
auto req = QNetworkRequest(QUrl(FURAFFINITY_BASE_URL "/submit/"));
req.setHeader(QNetworkRequest::UserAgentHeader, CLIENT_USER_AGENT);
//req.setRawHeader("Host", "www.furaffinity.net");
//req.setRawHeader("Referer", "http://www.furaffinity.net/submit/");
#ifndef FAC_DEBUG
req.setRawHeader("Host", "www.furaffinity.net");
req.setRawHeader("Referer", "http://www.furaffinity.net/submit/");
#endif
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::UserVerifiedRedirectPolicy);
auto obj = new QObject;
......@@ -206,7 +208,7 @@ void FurAffinityClient::uploadSubmissionFile(qlonglong uploadId)
auto mimeType = db.mimeTypeForFile(fi);
QHttpPart imagePart;
imagePart.setHeader(QNetworkRequest::ContentDispositionHeader,
QString("form-data; name=\"submission\"; filename=\"%1\"").arg(fi.baseName()));
QString("form-data; name=\"submission\"; filename=\"%1\"").arg(fi.fileName()));
auto imageFile = new QFile(upload->filePath());
imageFile->open(QIODevice::ReadOnly);
imagePart.setBodyDevice(imageFile);
......@@ -252,7 +254,7 @@ void FurAffinityClient::finaliseSubmission(qlonglong uploadId)
{
auto req = QNetworkRequest(QUrl(FURAFFINITY_BASE_URL "/submit/"));
req.setHeader(QNetworkRequest::UserAgentHeader, CLIENT_USER_AGENT);
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::UserVerifiedRedirectPolicy);
auto obj = new QObject;
obj->setProperty("requestOrigin", SubmitPart5);
......@@ -279,7 +281,19 @@ void FurAffinityClient::finaliseSubmission(qlonglong uploadId)
params.addQueryItem("create_folder_name", "");
params.addQueryItem("submit", "Finalize");
networkAccessManager->post(req, params.query().toUtf8());
auto reply = networkAccessManager->post(req, params.query().toUtf8());
connect(reply, &QNetworkReply::redirected, this, [&](const QUrl&) {
// yeah, the same workaround is required for normal POST requests.
// wtf? Qt pls
auto reply = qobject_cast<QNetworkReply*>(sender());
auto newRequest = QNetworkRequest(reply->url());
newRequest.setHeader(QNetworkRequest::UserAgentHeader, CLIENT_USER_AGENT);
newRequest.setAttribute(QNetworkRequest::RedirectPolicyAttribute,
QNetworkRequest::NoLessSafeRedirectPolicy);
newRequest.setOriginatingObject(reply->request().originatingObject());
networkAccessManager->get(newRequest);
reply->deleteLater();
});
upload->deleteLater();
}
......
......@@ -12,9 +12,15 @@
#include <libxml/HTMLparser.h>
#include <libxml/xpath.h>
//! The base URL for accessing FurAffinity.
#define FURAFFINITY_BASE_URL "https://www.furaffinity.net"
#define FURAFFINITY_BASE_URL "http://127.0.0.1:9292"
#define FAC_DEBUG 1
#ifdef FAC_DEBUG
//! The base URL for accessing FurAffinity.
#define FURAFFINITY_BASE_URL "http://127.0.0.1:9292"
#else
//! The base URL for accessing FurAffinity.
#define FURAFFINITY_BASE_URL "https://www.furaffinity.net"
#endif
#define CLIENT_USER_AGENT "Mozilla/5.0 (compatible; nFurAffinity) https://github.com/nilsding/nFurAffinity"
......
......@@ -34,7 +34,7 @@ post "/submit/?" do
when 5
raise ArgumentError, "key does not match" unless session[:submission][:key] == params["key"]
"Submission uploaded."
redirect "/view/1234567890/", 302
else
raise ArgumentError, "unknown part: #{params['part']}"
end
......@@ -45,3 +45,7 @@ get "/submit/submission/4/" do
erb :submit_4
end
get "/view/:id/" do
"This is the submission with the id #{params['id']}."
end