FeedReader: Added process of response code 403 and added user agent

This commit is contained in:
thunder2 2023-05-06 01:23:23 +02:00
parent ff183ee98b
commit 180b7d3703
5 changed files with 28 additions and 12 deletions

View File

@ -101,6 +101,9 @@ QString FeedReaderStringDefs::errorString(RsFeedReaderErrorState errorState, con
case RS_FEED_ERRORSTATE_DOWNLOAD_UNKOWN_RESPONSE_CODE:
errorText = QApplication::translate("FeedReaderStringDefs", "Unknown response code");
break;
case RS_FEED_ERRORSTATE_DOWNLOAD_BLOCKED:
errorText = QApplication::translate("FeedReaderStringDefs", "Download blocked");
break;
/* process */
case RS_FEED_ERRORSTATE_PROCESS_INTERNAL_ERROR:

View File

@ -43,6 +43,7 @@ enum RsFeedReaderErrorState {
RS_FEED_ERRORSTATE_DOWNLOAD_UNKNOWN_CONTENT_TYPE = 3,
RS_FEED_ERRORSTATE_DOWNLOAD_NOT_FOUND = 4,
RS_FEED_ERRORSTATE_DOWNLOAD_UNKOWN_RESPONSE_CODE = 5,
RS_FEED_ERRORSTATE_DOWNLOAD_BLOCKED = 6,
/* process */
RS_FEED_ERRORSTATE_PROCESS_INTERNAL_ERROR = 50,

View File

@ -9,7 +9,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+92"/>
<location line="+398"/>
<source>Board</source>
<translation type="unfinished"></translation>
</message>
@ -34,7 +34,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+12"/>
<location line="-391"/>
<source>Authentication (not yet supported)</source>
<translation type="unfinished"></translation>
</message>
@ -84,12 +84,12 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+121"/>
<location line="+88"/>
<source>Embed images</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-249"/>
<location line="-216"/>
<source>Storage time</source>
<translation type="unfinished"></translation>
</message>
@ -124,7 +124,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="-203"/>
<location line="+200"/>
<source>Type</source>
<translation type="unfinished"></translation>
</message>
@ -139,7 +139,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+299"/>
<location line="-67"/>
<source>Transformation</source>
<translation type="unfinished"></translation>
</message>
@ -154,7 +154,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+12"/>
<location line="-58"/>
<source>Misc</source>
<translation type="unfinished"></translation>
</message>
@ -169,17 +169,17 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="-336"/>
<location line="+100"/>
<source>Update forum information</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+350"/>
<location line="-86"/>
<source>Save complete web page (experimental for local feeds)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-103"/>
<location line="-70"/>
<source>Description:</source>
<translation type="unfinished"></translation>
</message>
@ -714,12 +714,12 @@
</message>
<message>
<location line="+3"/>
<location line="+108"/>
<location line="+111"/>
<source>Unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-91"/>
<location line="-94"/>
<source>Internal download error</source>
<translation type="unfinished"></translation>
</message>
@ -743,6 +743,11 @@
<source>Unknown response code</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+3"/>
<source>Download blocked</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+5"/>
<source>Internal process error</source>

View File

@ -302,6 +302,9 @@ RsFeedReaderErrorState p3FeedReaderThread::download(const RsFeedReaderFeed &feed
}
}
break;
case 403:
result = RS_FEED_ERRORSTATE_DOWNLOAD_BLOCKED;
break;
case 404:
result = RS_FEED_ERRORSTATE_DOWNLOAD_NOT_FOUND;
break;

View File

@ -21,6 +21,8 @@
#include "CURLWrapper.h"
#include <string.h>
#define USERAGENT "Mozilla/5.0 (rv:109.0) Gecko/20100101 Firefox/112.0"
CURLWrapper::CURLWrapper(const std::string &proxy)
{
mCurl = curl_easy_init();
@ -65,6 +67,7 @@ CURLcode CURLWrapper::downloadText(const std::string &link, std::string &data)
curl_easy_setopt(mCurl, CURLOPT_WRITEFUNCTION, writeFunctionString);
curl_easy_setopt(mCurl, CURLOPT_WRITEDATA, &data);
curl_easy_setopt(mCurl, CURLOPT_SSL_VERIFYPEER, false);
curl_easy_setopt(mCurl, CURLOPT_USERAGENT, USERAGENT);
return curl_easy_perform(mCurl);
}
@ -95,6 +98,7 @@ CURLcode CURLWrapper::downloadBinary(const std::string &link, std::vector<unsign
curl_easy_setopt(mCurl, CURLOPT_WRITEFUNCTION, writeFunctionBinary);
curl_easy_setopt(mCurl, CURLOPT_WRITEDATA, &data);
curl_easy_setopt(mCurl, CURLOPT_SSL_VERIFYPEER, false);
curl_easy_setopt(mCurl, CURLOPT_USERAGENT, USERAGENT);
return curl_easy_perform(mCurl);
}