src/network/access/qhttpnetworkreply.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   237 }
   237 }
   238 
   238 
   239 bool QHttpNetworkReplyPrivate::isGzipped()
   239 bool QHttpNetworkReplyPrivate::isGzipped()
   240 {
   240 {
   241     QByteArray encoding = headerField("content-encoding");
   241     QByteArray encoding = headerField("content-encoding");
   242     return encoding.toLower() == "gzip";
   242     return qstricmp(encoding.constData(), "gzip") == 0;
   243 }
   243 }
   244 
   244 
   245 void QHttpNetworkReplyPrivate::removeAutoDecompressHeader()
   245 void QHttpNetworkReplyPrivate::removeAutoDecompressHeader()
   246 {
   246 {
   247     // The header "Content-Encoding  = gzip" is retained.
   247     // The header "Content-Encoding  = gzip" is retained.
   248     // Content-Length is removed since the actual one send by the server is for compressed data
   248     // Content-Length is removed since the actual one send by the server is for compressed data
   249     QByteArray name("content-length");
   249     QByteArray name("content-length");
   250     QByteArray lowerName = name.toLower();
       
   251     QList<QPair<QByteArray, QByteArray> >::Iterator it = fields.begin(),
   250     QList<QPair<QByteArray, QByteArray> >::Iterator it = fields.begin(),
   252                                                    end = fields.end();
   251                                                    end = fields.end();
   253     while (it != end) {
   252     while (it != end) {
   254         if (name == it->first.toLower()) {
   253         if (qstricmp(name.constData(), it->first.constData()) == 0) {
   255             fields.erase(it);
   254             fields.erase(it);
   256             break;
   255             break;
   257         }
   256         }
   258         ++it;
   257         ++it;
   259     }
   258     }
   267     QByteArray header = forProxy ? "proxy-authenticate" : "www-authenticate";
   266     QByteArray header = forProxy ? "proxy-authenticate" : "www-authenticate";
   268     // pick the best protocol (has to match parsing in QAuthenticatorPrivate)
   267     // pick the best protocol (has to match parsing in QAuthenticatorPrivate)
   269     QList<QByteArray> challenges = headerFieldValues(header);
   268     QList<QByteArray> challenges = headerFieldValues(header);
   270     for (int i = 0; i<challenges.size(); i++) {
   269     for (int i = 0; i<challenges.size(); i++) {
   271         QByteArray line = challenges.at(i);
   270         QByteArray line = challenges.at(i);
       
   271         // todo use qstrincmp
   272         if (!line.toLower().startsWith("negotiate"))
   272         if (!line.toLower().startsWith("negotiate"))
   273             challenge = line;
   273             challenge = line;
   274     }
   274     }
   275     return !challenge.isEmpty();
   275     return !challenge.isEmpty();
   276 }
   276 }