mirror of https://github.com/vitalif/phantomjs
Migrate network access manager settings to PhantomConfig
parent
5441f51607
commit
a445b2d7b9
|
@ -55,11 +55,8 @@ Phantom::Phantom(QObject *parent)
|
|||
m_page = new WebPage(this);
|
||||
m_pages.append(m_page);
|
||||
|
||||
QString cookieFile;
|
||||
bool autoLoadImages = true;
|
||||
bool pluginsEnabled = false;
|
||||
bool diskCacheEnabled = false;
|
||||
bool ignoreSslErrors = false;
|
||||
bool localAccessRemote = false;
|
||||
|
||||
// second argument: script name
|
||||
|
@ -94,19 +91,19 @@ Phantom::Phantom(QObject *parent)
|
|||
continue;
|
||||
}
|
||||
if (arg == "--disk-cache=yes") {
|
||||
diskCacheEnabled = true;
|
||||
m_config.setDiskCacheEnabled(true);
|
||||
continue;
|
||||
}
|
||||
if (arg == "--disk-cache=no") {
|
||||
diskCacheEnabled = false;
|
||||
m_config.setDiskCacheEnabled(false);
|
||||
continue;
|
||||
}
|
||||
if (arg == "--ignore-ssl-errors=yes") {
|
||||
ignoreSslErrors = true;
|
||||
m_config.setIgnoreSslErrors(true);
|
||||
continue;
|
||||
}
|
||||
if (arg == "--ignore-ssl-errors=no") {
|
||||
ignoreSslErrors = false;
|
||||
m_config.setIgnoreSslErrors(false);
|
||||
continue;
|
||||
}
|
||||
if (arg == "--local-access-remote=no") {
|
||||
|
@ -122,7 +119,7 @@ Phantom::Phantom(QObject *parent)
|
|||
continue;
|
||||
}
|
||||
if (arg.startsWith("--cookies=")) {
|
||||
cookieFile = arg.mid(10).trimmed();
|
||||
m_config.setCookieFile(arg.mid(10).trimmed());
|
||||
continue;
|
||||
}
|
||||
if (arg.startsWith("--output-encoding=")) {
|
||||
|
@ -168,7 +165,7 @@ Phantom::Phantom(QObject *parent)
|
|||
m_scriptFileEnc.setEncoding(m_config.scriptEncoding());
|
||||
|
||||
// Provide WebPage with a non-standard Network Access Manager
|
||||
m_netAccessMan = new NetworkAccessManager(this, diskCacheEnabled, cookieFile, ignoreSslErrors);
|
||||
m_netAccessMan = new NetworkAccessManager(this, m_config.diskCacheEnabled(), m_config.cookieFile(), m_config.ignoreSslErrors());
|
||||
m_page->setNetworkAccessManager(m_netAccessMan);
|
||||
|
||||
connect(m_page, SIGNAL(javaScriptConsoleMessageSent(QString, int, QString)),
|
||||
|
|
|
@ -41,6 +41,36 @@ void PhantomConfig::load()
|
|||
resetToDefaults();
|
||||
}
|
||||
|
||||
QString PhantomConfig::cookieFile() const
|
||||
{
|
||||
return m_cookieFile;
|
||||
}
|
||||
|
||||
void PhantomConfig::setCookieFile(const QString &value)
|
||||
{
|
||||
m_cookieFile = value;
|
||||
}
|
||||
|
||||
bool PhantomConfig::diskCacheEnabled() const
|
||||
{
|
||||
return m_diskCacheEnabled;
|
||||
}
|
||||
|
||||
void PhantomConfig::setDiskCacheEnabled(const bool value)
|
||||
{
|
||||
m_diskCacheEnabled = value;
|
||||
}
|
||||
|
||||
bool PhantomConfig::ignoreSslErrors() const
|
||||
{
|
||||
return m_ignoreSslErrors;
|
||||
}
|
||||
|
||||
void PhantomConfig::setIgnoreSslErrors(const bool value)
|
||||
{
|
||||
m_ignoreSslErrors = value;
|
||||
}
|
||||
|
||||
QString PhantomConfig::outputEncoding() const
|
||||
{
|
||||
return m_outputEncoding;
|
||||
|
@ -100,6 +130,9 @@ void PhantomConfig::setScriptEncoding(const QString &value)
|
|||
// private:
|
||||
void PhantomConfig::resetToDefaults()
|
||||
{
|
||||
m_cookieFile = QString();
|
||||
m_diskCacheEnabled = false;
|
||||
m_ignoreSslErrors = false;
|
||||
m_outputEncoding = "UTF-8";
|
||||
m_proxyHost = QString();
|
||||
m_proxyPort = 1080;
|
||||
|
|
|
@ -40,6 +40,15 @@ public:
|
|||
|
||||
void load();
|
||||
|
||||
QString cookieFile() const;
|
||||
void setCookieFile(const QString &cookieFile);
|
||||
|
||||
bool diskCacheEnabled() const;
|
||||
void setDiskCacheEnabled(const bool value);
|
||||
|
||||
bool ignoreSslErrors() const;
|
||||
void setIgnoreSslErrors(const bool value);
|
||||
|
||||
QString outputEncoding() const;
|
||||
void setOutputEncoding(const QString &value);
|
||||
|
||||
|
@ -55,6 +64,9 @@ private:
|
|||
void setProxyHost(const QString &value);
|
||||
void setProxyPort(const int value);
|
||||
|
||||
QString m_cookieFile;
|
||||
bool m_diskCacheEnabled;
|
||||
bool m_ignoreSslErrors;
|
||||
QString m_outputEncoding;
|
||||
QString m_proxyHost;
|
||||
int m_proxyPort;
|
||||
|
|
Loading…
Reference in New Issue