68 int qHash(
const QSslError error) {
69 return qHash(error.error());
80 void HttpSettings::setDefaultValues() {
82 m_address = QHostAddress::Any;
87 m_indexFile =
"index.html";
88 m_sessionCookieName =
"sessionid";
89 m_sessionExpirationTime = 3600;
90 m_maxRequestSize = 16384;
91 m_maxMultiPartSize = 16728064;
95 m_default_section2 =
"http";
96 m_default_port = 8080;
97 m_default_address = QHostAddress::Any;
98 m_default_timeout = 600;
99 m_default_maxAge = 3600;
100 m_default_encoding =
"UTF-8";
101 m_default_docroot =
".";
102 m_default_indexFile =
"index.html";
103 m_default_sessionCookieName =
"sessionid";
104 m_default_sessionExpirationTime = 3600;
105 m_default_maxRequestSize = 16384;
106 m_default_maxMultiPartSize = 16728064;
107 m_default_useSSL =
false;
108 m_default_sslKey =
"";
109 m_default_sslCrt =
"";
110 m_default_sslCaCrt =
"";
111 m_default_ignoreAllSslErrors =
true;
112 m_default_threads =
true;
113 m_default_gzip =
true;
118 m_section2 = section2;
124 m_port = settings->value( section +
"/port",
125 settings->value(m_section2 +
"/port", m_default_port)).toInt();
126 if (settings->contains(section+
"/address")) {
127 m_address = settings->value(section+
"/address").toString();
129 }
else if (settings->contains(m_section2+
"/address")) {
130 m_address = settings->value(m_section2+
"/address").toString();
134 m_address = m_default_address;
136 m_timeout = settings->value( section +
"/timeout",
137 settings->value(m_section2 +
"/timeout", m_default_timeout)).toInt();
138 m_maxAge = settings->value( section +
"/maxAge",
139 settings->value(m_section2 +
"/maxAge", m_default_maxAge)).toInt();
140 m_encoding = settings->value( section +
"/encoding",
141 settings->value(m_section2 +
"/encoding", m_default_encoding)).toString();
142 m_docroot = settings->value( section +
"/root",
143 settings->value(m_section2 +
"/root", m_default_docroot)).toString();
144 m_indexFile = settings->value( section +
"/indexFile",
145 settings->value(m_section2 +
"/indexFile", m_default_indexFile)).toString();
146 m_sessionCookieName = settings->value( section +
"/sessionCookieName",
147 settings->value(m_section2 +
"/sessionCookieName", m_default_sessionCookieName)).toString();
148 m_sessionExpirationTime = settings->value( section +
"/sessionExpirationTime",
149 settings->value(m_section2 +
"/sessionExpirationTime", m_default_sessionExpirationTime)).toInt();
150 m_maxRequestSize = settings->value( section +
"/maxRequestSize",
151 settings->value(m_section2 +
"/maxRequestSize", m_default_maxRequestSize)).toInt();
152 m_maxMultiPartSize = settings->value( section +
"/maxMultiPartSize",
153 settings->value(m_section2 +
"/maxMultiPartSize", m_default_maxMultiPartSize)).toInt();
154 m_useSSL = settings->value( section +
"/useSSL",
155 settings->value(m_section2 +
"/useSSL", m_default_useSSL)).toBool();
156 m_sslKey = settings->value( section +
"/sslKey",
157 settings->value(m_section2 +
"/sslKey", m_default_sslKey)).toString();
158 m_sslCrt = settings->value( section +
"/sslCrt",
159 settings->value(m_section2 +
"/sslCrt", m_default_sslCrt)).toString();
160 m_sslCaCrt = settings->value( section +
"/sslCaCrt",
161 settings->value(m_section2 +
"/sslCaCrt", m_default_sslCaCrt)).toString();
162 m_ignoreAllSslErrors = settings->value( section +
"/IgnoreAllSslErrors",
163 settings->value(m_section2 +
"/IgnoreAllSslErrors", m_default_ignoreAllSslErrors)).toBool();
164 m_threads = settings->value( section +
"/threads",
165 settings->value(m_section2 +
"/threads", m_default_threads)).toBool();
166 m_gzip = settings->value( section +
"/gzip",
167 settings->value(m_section2 +
"/gzip", m_default_gzip)).toBool();
169 #define SSLERROR(x) { if (settings->value( section + "/Ignore" + #x, \ 170 settings->value(m_section2 + "/Ignore" + #x, false)).toBool()) { \ 171 m_sslErrors << QSslError::x; \ 175 SSLERROR(UnableToGetIssuerCertificate);
176 SSLERROR(UnableToDecryptCertificateSignature);
177 SSLERROR(UnableToDecodeIssuerPublicKey);
178 SSLERROR(CertificateSignatureFailed);
179 SSLERROR(CertificateNotYetValid);
180 SSLERROR(CertificateExpired);
181 SSLERROR(InvalidNotBeforeField);
182 SSLERROR(InvalidNotAfterField);
183 SSLERROR(SelfSignedCertificate);
184 SSLERROR(SelfSignedCertificateInChain);
185 SSLERROR(UnableToGetLocalIssuerCertificate);
186 SSLERROR(UnableToVerifyFirstCertificate);
187 SSLERROR(CertificateRevoked);
188 SSLERROR(InvalidCaCertificate);
189 SSLERROR(PathLengthExceeded);
190 SSLERROR(InvalidPurpose);
191 SSLERROR(CertificateUntrusted);
192 SSLERROR(CertificateRejected);
193 SSLERROR(SubjectIssuerMismatch);
194 SSLERROR(AuthorityIssuerSerialNumberMismatch);
195 SSLERROR(NoPeerCertificate);
196 SSLERROR(HostNameMismatch);
197 SSLERROR(UnspecifiedError);
198 SSLERROR(NoSslSupport);
199 #if QT_VERSION > 0x040700 200 SSLERROR(CertificateBlacklisted);
208 QString m_section2 =
"http";
215 QString m_section2 =
"http";
221 if (m_ignoreAllSslErrors) {
224 return m_sslErrors.contains(error);
void readSettings(const QSettings *settings, const QString §ion, const QString §ion2)
Read settings from configuration file.
bool ignoreSslError(QSslError error) const
Returns true if the error should be ignored, default true.
HttpSettings(QObject *parent)
Constructor reads default QSettings file section [httpd].
Namespace of HTTP server.