OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 const AtomicString& ResourceResponse::httpStatusText() const | 260 const AtomicString& ResourceResponse::httpStatusText() const |
261 { | 261 { |
262 return m_httpStatusText; | 262 return m_httpStatusText; |
263 } | 263 } |
264 | 264 |
265 void ResourceResponse::setHTTPStatusText(const AtomicString& statusText) | 265 void ResourceResponse::setHTTPStatusText(const AtomicString& statusText) |
266 { | 266 { |
267 m_httpStatusText = statusText; | 267 m_httpStatusText = statusText; |
268 } | 268 } |
269 | 269 |
270 AtomicString ResourceResponse::httpHeaderField(const AtomicString& name) const | 270 const AtomicString& ResourceResponse::httpHeaderField(const AtomicString& name)
const |
271 { | 271 { |
272 return m_httpHeaderFields.get(name); | 272 return m_httpHeaderFields.get(name); |
273 } | 273 } |
274 | 274 |
275 const AtomicString& ResourceResponse::httpHeaderField(const char* name) const | 275 const AtomicString& ResourceResponse::httpHeaderField(const char* name) const |
276 { | 276 { |
277 return m_httpHeaderFields.get(name); | 277 return m_httpHeaderFields.get(name); |
278 } | 278 } |
279 | 279 |
280 void ResourceResponse::updateHeaderParsedState(const AtomicString& name) | 280 void ResourceResponse::updateHeaderParsedState(const AtomicString& name) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 m_cacheControlContainsMustRevalidate = false; | 333 m_cacheControlContainsMustRevalidate = false; |
334 m_cacheControlContainsNoCache = false; | 334 m_cacheControlContainsNoCache = false; |
335 m_cacheControlMaxAge = std::numeric_limits<double>::quiet_NaN(); | 335 m_cacheControlMaxAge = std::numeric_limits<double>::quiet_NaN(); |
336 | 336 |
337 DEFINE_STATIC_LOCAL(const AtomicString, cacheControlString, ("cache-control"
, AtomicString::ConstructFromLiteral)); | 337 DEFINE_STATIC_LOCAL(const AtomicString, cacheControlString, ("cache-control"
, AtomicString::ConstructFromLiteral)); |
338 DEFINE_STATIC_LOCAL(const AtomicString, noCacheDirective, ("no-cache", Atomi
cString::ConstructFromLiteral)); | 338 DEFINE_STATIC_LOCAL(const AtomicString, noCacheDirective, ("no-cache", Atomi
cString::ConstructFromLiteral)); |
339 DEFINE_STATIC_LOCAL(const AtomicString, noStoreDirective, ("no-store", Atomi
cString::ConstructFromLiteral)); | 339 DEFINE_STATIC_LOCAL(const AtomicString, noStoreDirective, ("no-store", Atomi
cString::ConstructFromLiteral)); |
340 DEFINE_STATIC_LOCAL(const AtomicString, mustRevalidateDirective, ("must-reva
lidate", AtomicString::ConstructFromLiteral)); | 340 DEFINE_STATIC_LOCAL(const AtomicString, mustRevalidateDirective, ("must-reva
lidate", AtomicString::ConstructFromLiteral)); |
341 DEFINE_STATIC_LOCAL(const AtomicString, maxAgeDirective, ("max-age", AtomicS
tring::ConstructFromLiteral)); | 341 DEFINE_STATIC_LOCAL(const AtomicString, maxAgeDirective, ("max-age", AtomicS
tring::ConstructFromLiteral)); |
342 | 342 |
343 AtomicString cacheControlValue = m_httpHeaderFields.get(cacheControlString); | 343 const AtomicString& cacheControlValue = m_httpHeaderFields.get(cacheControlS
tring); |
344 if (!cacheControlValue.isEmpty()) { | 344 if (!cacheControlValue.isEmpty()) { |
345 Vector<pair<String, String> > directives; | 345 Vector<pair<String, String> > directives; |
346 parseCacheHeader(cacheControlValue, directives); | 346 parseCacheHeader(cacheControlValue, directives); |
347 | 347 |
348 size_t directivesSize = directives.size(); | 348 size_t directivesSize = directives.size(); |
349 for (size_t i = 0; i < directivesSize; ++i) { | 349 for (size_t i = 0; i < directivesSize; ++i) { |
350 // RFC2616 14.9.1: A no-cache directive with a value is only meaning
ful for proxy caches. | 350 // RFC2616 14.9.1: A no-cache directive with a value is only meaning
ful for proxy caches. |
351 // It should be ignored by a browser level cache. | 351 // It should be ignored by a browser level cache. |
352 if (equalIgnoringCase(directives[i].first, noCacheDirective) && dire
ctives[i].second.isEmpty()) | 352 if (equalIgnoringCase(directives[i].first, noCacheDirective) && dire
ctives[i].second.isEmpty()) |
353 m_cacheControlContainsNoCache = true; | 353 m_cacheControlContainsNoCache = true; |
(...skipping 12 matching lines...) Expand all Loading... |
366 m_cacheControlMaxAge = maxAge; | 366 m_cacheControlMaxAge = maxAge; |
367 } | 367 } |
368 } | 368 } |
369 } | 369 } |
370 | 370 |
371 if (!m_cacheControlContainsNoCache) { | 371 if (!m_cacheControlContainsNoCache) { |
372 // Handle Pragma: no-cache | 372 // Handle Pragma: no-cache |
373 // This is deprecated and equivalent to Cache-control: no-cache | 373 // This is deprecated and equivalent to Cache-control: no-cache |
374 // Don't bother tokenizing the value, it is not important | 374 // Don't bother tokenizing the value, it is not important |
375 DEFINE_STATIC_LOCAL(const AtomicString, pragmaHeader, ("pragma", AtomicS
tring::ConstructFromLiteral)); | 375 DEFINE_STATIC_LOCAL(const AtomicString, pragmaHeader, ("pragma", AtomicS
tring::ConstructFromLiteral)); |
376 String pragmaValue = m_httpHeaderFields.get(pragmaHeader); | 376 const AtomicString& pragmaValue = m_httpHeaderFields.get(pragmaHeader); |
377 | 377 |
378 m_cacheControlContainsNoCache = pragmaValue.lower().contains(noCacheDire
ctive); | 378 m_cacheControlContainsNoCache = pragmaValue.lower().contains(noCacheDire
ctive); |
379 } | 379 } |
380 } | 380 } |
381 | 381 |
382 bool ResourceResponse::cacheControlContainsNoCache() const | 382 bool ResourceResponse::cacheControlContainsNoCache() const |
383 { | 383 { |
384 if (!m_haveParsedCacheControlHeader) | 384 if (!m_haveParsedCacheControlHeader) |
385 parseCacheControlDirectives(); | 385 parseCacheControlDirectives(); |
386 return m_cacheControlContainsNoCache; | 386 return m_cacheControlContainsNoCache; |
(...skipping 22 matching lines...) Expand all Loading... |
409 | 409 |
410 double ResourceResponse::cacheControlMaxAge() const | 410 double ResourceResponse::cacheControlMaxAge() const |
411 { | 411 { |
412 if (!m_haveParsedCacheControlHeader) | 412 if (!m_haveParsedCacheControlHeader) |
413 parseCacheControlDirectives(); | 413 parseCacheControlDirectives(); |
414 return m_cacheControlMaxAge; | 414 return m_cacheControlMaxAge; |
415 } | 415 } |
416 | 416 |
417 static double parseDateValueInHeader(const HTTPHeaderMap& headers, const AtomicS
tring& headerName) | 417 static double parseDateValueInHeader(const HTTPHeaderMap& headers, const AtomicS
tring& headerName) |
418 { | 418 { |
419 String headerValue = headers.get(headerName); | 419 const AtomicString& headerValue = headers.get(headerName); |
420 if (headerValue.isEmpty()) | 420 if (headerValue.isEmpty()) |
421 return std::numeric_limits<double>::quiet_NaN(); | 421 return std::numeric_limits<double>::quiet_NaN(); |
422 // This handles all date formats required by RFC2616: | 422 // This handles all date formats required by RFC2616: |
423 // Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 | 423 // Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 |
424 // Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 | 424 // Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 |
425 // Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format | 425 // Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format |
426 double dateInMilliseconds = parseDate(headerValue); | 426 double dateInMilliseconds = parseDate(headerValue); |
427 if (!std::isfinite(dateInMilliseconds)) | 427 if (!std::isfinite(dateInMilliseconds)) |
428 return std::numeric_limits<double>::quiet_NaN(); | 428 return std::numeric_limits<double>::quiet_NaN(); |
429 return dateInMilliseconds / 1000; | 429 return dateInMilliseconds / 1000; |
430 } | 430 } |
431 | 431 |
432 double ResourceResponse::date() const | 432 double ResourceResponse::date() const |
433 { | 433 { |
434 if (!m_haveParsedDateHeader) { | 434 if (!m_haveParsedDateHeader) { |
435 DEFINE_STATIC_LOCAL(const AtomicString, headerName, ("date", AtomicStrin
g::ConstructFromLiteral)); | 435 DEFINE_STATIC_LOCAL(const AtomicString, headerName, ("date", AtomicStrin
g::ConstructFromLiteral)); |
436 m_date = parseDateValueInHeader(m_httpHeaderFields, headerName); | 436 m_date = parseDateValueInHeader(m_httpHeaderFields, headerName); |
437 m_haveParsedDateHeader = true; | 437 m_haveParsedDateHeader = true; |
438 } | 438 } |
439 return m_date; | 439 return m_date; |
440 } | 440 } |
441 | 441 |
442 double ResourceResponse::age() const | 442 double ResourceResponse::age() const |
443 { | 443 { |
444 if (!m_haveParsedAgeHeader) { | 444 if (!m_haveParsedAgeHeader) { |
445 DEFINE_STATIC_LOCAL(const AtomicString, headerName, ("age", AtomicString
::ConstructFromLiteral)); | 445 DEFINE_STATIC_LOCAL(const AtomicString, headerName, ("age", AtomicString
::ConstructFromLiteral)); |
446 String headerValue = m_httpHeaderFields.get(headerName); | 446 const AtomicString& headerValue = m_httpHeaderFields.get(headerName); |
447 bool ok; | 447 bool ok; |
448 m_age = headerValue.toDouble(&ok); | 448 m_age = headerValue.toDouble(&ok); |
449 if (!ok) | 449 if (!ok) |
450 m_age = std::numeric_limits<double>::quiet_NaN(); | 450 m_age = std::numeric_limits<double>::quiet_NaN(); |
451 m_haveParsedAgeHeader = true; | 451 m_haveParsedAgeHeader = true; |
452 } | 452 } |
453 return m_age; | 453 return m_age; |
454 } | 454 } |
455 | 455 |
456 double ResourceResponse::expires() const | 456 double ResourceResponse::expires() const |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 pos += nextCommaPosition - pos + 1; | 674 pos += nextCommaPosition - pos + 1; |
675 } else { | 675 } else { |
676 // Add last directive to map with empty string as value | 676 // Add last directive to map with empty string as value |
677 result.append(pair<String, String>(trimToNextSeparator(safeHeader.su
bstring(pos, max - pos).stripWhiteSpace()), "")); | 677 result.append(pair<String, String>(trimToNextSeparator(safeHeader.su
bstring(pos, max - pos).stripWhiteSpace()), "")); |
678 return; | 678 return; |
679 } | 679 } |
680 } | 680 } |
681 } | 681 } |
682 | 682 |
683 } | 683 } |
OLD | NEW |