bool ThreadAccess::readCacheHeader( FILE* fs, const KURL& url )
{
+ QFile file;
+ file.open( IO_ReadOnly, fs );
+
char buffer[ 401 ];
// CacheRevision
- if ( !fgets( buffer, 400, fs ) ) {
+ if ( file.readLine( buffer, 400 ) == -1 ) {
return false;
}
if ( strcmp( buffer, "7\n" ) != 0 ) {
}
// URL
- if ( !fgets( buffer, 400, fs ) ) {
+ if ( file.readLine( buffer, 400 ) == -1 ) {
return false;
}
}
// Creation Date
- if ( !fgets( buffer, 400, fs ) ) {
+ if ( file.readLine( buffer, 400 ) == -1 ) {
return false;
}
// Expiration Date
- if ( !fgets( buffer, 400, fs ) ) {
+ if ( file.readLine( buffer, 400 ) == -1 ) {
return false;
}
// ETag
- if ( !fgets( buffer, 400, fs ) ) {
+ if ( file.readLine( buffer, 400 ) == -1 ) {
return false;
}
// Last-Modified
- if ( !fgets( buffer, 400, fs ) ) {
+ if ( file.readLine( buffer, 400 ) == -1 ) {
return false;
}
// Mime-Type
- if ( !fgets( buffer, 400, fs ) ) {
+ if ( file.readLine( buffer, 400 ) == -1 ) {
return false;
}
// Charset
- if ( !fgets( buffer, 400, fs ) ) {
+ if ( file.readLine( buffer, 400 ) == -1 ) {
return false;
}
return ;
}
- char buffer[ 401 ];
- bool ok = true;
-
- // CacheRevision
- if ( ok && ( !fgets( buffer, 400, fs ) ) )
- ok = false;
- if ( ok && ( strcmp( buffer, "7\n" ) != 0 ) )
- ok = false;
-
- // URL
- if ( ok && ( !fgets( buffer, 400, fs ) ) )
- ok = false;
- if ( ok ) {
- int l = strlen( buffer );
- if ( l > 0 )
- buffer[ l - 1 ] = 0; // Strip newline
- if ( url.url() != buffer ) {
- ok = false; // Hash collision
- }
- }
-
- // Creation Date
- if ( ok && ( !fgets( buffer, 400, fs ) ) )
- ok = false;
-
- // Expiration Date
- if ( ok && ( !fgets( buffer, 400, fs ) ) )
- ok = false;
-
- // ETag
- if ( ok && ( !fgets( buffer, 400, fs ) ) )
- ok = false;
-
- // Last-Modified
- if ( ok && ( !fgets( buffer, 400, fs ) ) )
- ok = false;
-
- // Mime-Type
- if ( ok && ( !fgets( buffer, 400, fs ) ) )
- ok = false;
-
- // Charset
- if ( ok && ( !fgets( buffer, 400, fs ) ) )
- ok = false;
-
- if ( ok ) {
+ if ( readCacheHeader( fs, url ) ) {
if ( m_orgData && responseCode() == 304 ) {
// datÍî¤Á¤é¤·¤¾ì¹ç
m_threadData = m_orgData;