mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
set Origin header
This commit is contained in:
parent
cf26b33bde
commit
6e984feb38
|
@ -3,32 +3,31 @@
|
|||
#include "utils.hh"
|
||||
#include "globalbroadcaster.h"
|
||||
|
||||
WebUrlRequestInterceptor::WebUrlRequestInterceptor(QObject *p)
|
||||
:QWebEngineUrlRequestInterceptor(p)
|
||||
WebUrlRequestInterceptor::WebUrlRequestInterceptor( QObject * p ):
|
||||
QWebEngineUrlRequestInterceptor( p )
|
||||
{
|
||||
}
|
||||
void WebUrlRequestInterceptor::interceptRequest( QWebEngineUrlRequestInfo & info )
|
||||
{
|
||||
|
||||
}
|
||||
void WebUrlRequestInterceptor::interceptRequest( QWebEngineUrlRequestInfo &info) {
|
||||
info.setHttpHeader("origin",Utils::Url::getHostBaseFromUrl(info.requestUrl()).toUtf8());
|
||||
info.setHttpHeader("referer",info.requestUrl().url().toUtf8());
|
||||
if( GlobalBroadcaster::instance()->getPreference()->disallowContentFromOtherSites && Utils::isExternalLink( info.requestUrl() ) )
|
||||
{
|
||||
info.setHttpHeader( "origin", "*" );
|
||||
info.setHttpHeader( "referer", info.requestUrl().url().toUtf8() );
|
||||
if ( GlobalBroadcaster::instance()->getPreference()->disallowContentFromOtherSites
|
||||
&& Utils::isExternalLink( info.requestUrl() ) ) {
|
||||
//file:// link ,pass
|
||||
if(info.requestUrl().scheme()=="file"){
|
||||
if ( info.requestUrl().scheme() == "file" ) {
|
||||
return;
|
||||
}
|
||||
auto hostBase = Utils::Url::getHostBase( info.requestUrl().host() );
|
||||
if( GlobalBroadcaster::instance()->existedInWhitelist( hostBase ) )
|
||||
{
|
||||
if ( GlobalBroadcaster::instance()->existedInWhitelist( hostBase ) ) {
|
||||
//whitelist url does not block
|
||||
return;
|
||||
}
|
||||
if( info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeImage
|
||||
|| info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeFontResource
|
||||
|| info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeStylesheet
|
||||
|| info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMedia
|
||||
|| Utils::isHtmlResources( info.requestUrl() ) )
|
||||
{
|
||||
if ( info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeImage
|
||||
|| info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeFontResource
|
||||
|| info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeStylesheet
|
||||
|| info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMedia
|
||||
|| Utils::isHtmlResources( info.requestUrl() ) ) {
|
||||
//let throuth the resources file.
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue