From kde-commits Wed Sep 26 17:08:44 2007 From: Allan Sandfeld Jensen Date: Wed, 26 Sep 2007 17:08:44 +0000 To: kde-commits Subject: branches/KDE/3.5/kdelibs/kioslave/http Message-Id: <1190826524.330970.661.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=119082653321043 SVN commit 717341 by carewolf: Revert r707381 which broke http-headers, and add a bit more buffer to handle long http-headers like X-JSON which r707381 tried to fix. M +12 -15 http.cc M +2 -2 http.h --- branches/KDE/3.5/kdelibs/kioslave/http/http.cc #717340:717341 @@ -263,11 +263,11 @@ m_bChunked = false; m_iSize = NO_SIZE; + m_responseHeader.clear(); m_qContentEncodings.clear(); m_qTransferEncodings.clear(); m_sContentMD5 = QString::null; m_strMimeType = QString::null; - m_responseHeader = QString::null; setMetaData("request-id", m_request.id); } @@ -2647,13 +2647,10 @@ // Send the response header if it was requested if ( config()->readBoolEntry("PropagateHttpHeader", false) ) { - setMetaData("HTTP-Headers", m_responseHeader); + setMetaData("HTTP-Headers", m_responseHeader.join("\n")); sendMetaData(); - //kdDebug(7113) << "(" << m_pid << ") HTTPProtocol::forwardHttpResponseHeader =====" << endl; - //kdDebug(7113) << "(" << m_pid << m_responseHeader << endl; } - - m_responseHeader = QString::null; + m_responseHeader.clear(); } /** @@ -2670,7 +2667,7 @@ // Check if (m_request.bCachedRead) { - m_responseHeader = QString::fromLatin1("HTTP-CACHE"); + m_responseHeader << "HTTP-CACHE"; // Read header from cache... char buffer[4097]; if (!fgets(buffer, 4096, m_request.fcache) ) @@ -2738,9 +2735,9 @@ int maxAge = -1; // -1 = no max age, 0 already expired, > 0 = actual time int maxHeaderSize = 64*1024; // 64Kb to catch DOS-attacks - // read in 4096 bytes at a time (HTTP cookies can be quite large.) + // read in 8192 bytes at a time (HTTP cookies can be quite large.) int len = 0; - char buffer[4097]; + char buffer[8193]; bool cont = false; bool cacheValidated = false; // Revalidation was successful bool mayCache = true; @@ -2843,7 +2840,7 @@ // Store the the headers so they can be passed to the // calling application later - m_responseHeader += QString::fromLatin1(buf); + m_responseHeader << QString::fromLatin1(buf); if ((strncasecmp(buf, "HTTP", 4) == 0) || (strncasecmp(buf, "ICY ", 4) == 0)) // Shoutcast support @@ -3412,7 +3409,7 @@ } while (!m_bEOF && (len || noHeader) && (headerSize < maxHeaderSize) && (gets(buffer, sizeof(buffer)-1))); - // Send the current response before processing starts or it + // Send the current response before processing starts or it // might never get sent... forwardHttpResponseHeader(); @@ -3611,7 +3608,7 @@ (m_request.url.host() == u.host()) && (m_request.url.protocol() == u.protocol())) u.setRef(m_request.url.ref()); - + m_bRedirect = true; m_redirectLocation = u; @@ -3680,7 +3677,7 @@ m_strMimeType != "application/x-tgz" && m_strMimeType != "application/x-targz" && m_strMimeType != "application/x-gzip" && - m_request.url.path().right(6) == ".ps.gz" ) + m_request.url.path().right(6) == ".ps.gz" ) { m_qContentEncodings.remove(m_qContentEncodings.fromLast()); m_strMimeType = QString::fromLatin1("application/x-gzpostscript"); @@ -4539,7 +4536,7 @@ { if (m_request.bCachedWrite && m_request.fcache) closeCacheEntry(); - else if (m_request.bCachedWrite) + else if (m_request.bCachedWrite) kdDebug(7113) << "(" << m_pid << ") no cache file!\n"; } else @@ -4550,7 +4547,7 @@ if (sz <= 1) { - /* kdDebug(7113) << "(" << m_pid << ") readBody: sz = " << KIO::number(sz) + /* kdDebug(7113) << "(" << m_pid << ") readBody: sz = " << KIO::number(sz) << ", responseCode =" << m_responseCode << endl; */ if (m_responseCode >= 500 && m_responseCode <= 599) error(ERR_INTERNAL_SERVER, m_state.hostname); --- branches/KDE/3.5/kdelibs/kioslave/http/http.h #717340:717341 @@ -475,7 +475,7 @@ bool m_bEOD; //--- Settings related to a single response only - QString m_responseHeader; // All response headers + QStringList m_responseHeader; // All headers KURL m_redirectLocation; bool m_bRedirect; // Indicates current request is a redirection @@ -487,7 +487,7 @@ QByteArray m_bufReceive; // Receive buffer bool m_dataInternal; // Data is for internal consumption char m_lineBuf[1024]; - char m_rewindBuf[4096]; + char m_rewindBuf[8192]; size_t m_rewindCount; char *m_linePtr; size_t m_lineCount;