1/* 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2009 Google Inc. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include "config.h" 28#include "ResourceResponseBase.h" 29 30#include "HTTPHeaderNames.h" 31#include "HTTPParsers.h" 32#include "ResourceResponse.h" 33#include <wtf/CurrentTime.h> 34#include <wtf/MathExtras.h> 35#include <wtf/StdLibExtras.h> 36#include <wtf/text/StringView.h> 37 38namespace WebCore { 39 40static void parseCacheHeader(const String& header, Vector<std::pair<String, String>>& result); 41 42inline const ResourceResponse& ResourceResponseBase::asResourceResponse() const 43{ 44 return *static_cast<const ResourceResponse*>(this); 45} 46 47ResourceResponseBase::ResourceResponseBase() 48 : m_expectedContentLength(0) 49 , m_httpStatusCode(0) 50 , m_connectionID(0) 51 , m_cacheControlMaxAge(0) 52 , m_age(0) 53 , m_date(0) 54 , m_expires(0) 55 , m_lastModified(0) 56 , m_wasCached(false) 57 , m_connectionReused(false) 58 , m_isNull(true) 59 , m_haveParsedCacheControlHeader(false) 60 , m_haveParsedAgeHeader(false) 61 , m_haveParsedDateHeader(false) 62 , m_haveParsedExpiresHeader(false) 63 , m_haveParsedLastModifiedHeader(false) 64 , m_cacheControlContainsNoCache(false) 65 , m_cacheControlContainsNoStore(false) 66 , m_cacheControlContainsMustRevalidate(false) 67{ 68} 69 70ResourceResponseBase::ResourceResponseBase(const URL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename) 71 : m_url(url) 72 , m_mimeType(mimeType) 73 , m_expectedContentLength(expectedLength) 74 , m_textEncodingName(textEncodingName) 75 , m_suggestedFilename(filename) 76 , m_httpStatusCode(0) 77 , m_connectionID(0) 78 , m_cacheControlMaxAge(0) 79 , m_age(0) 80 , m_date(0) 81 , m_expires(0) 82 , m_lastModified(0) 83 , m_wasCached(false) 84 , m_connectionReused(false) 85 , m_isNull(false) 86 , m_haveParsedCacheControlHeader(false) 87 , m_haveParsedAgeHeader(false) 88 , m_haveParsedDateHeader(false) 89 , m_haveParsedExpiresHeader(false) 90 , m_haveParsedLastModifiedHeader(false) 91 , m_cacheControlContainsNoCache(false) 92 , m_cacheControlContainsNoStore(false) 93 , m_cacheControlContainsMustRevalidate(false) 94{ 95} 96 97PassOwnPtr<ResourceResponse> ResourceResponseBase::adopt(PassOwnPtr<CrossThreadResourceResponseData> data) 98{ 99 OwnPtr<ResourceResponse> response = adoptPtr(new ResourceResponse); 100 response->setURL(data->m_url); 101 response->setMimeType(data->m_mimeType); 102 response->setExpectedContentLength(data->m_expectedContentLength); 103 response->setTextEncodingName(data->m_textEncodingName); 104 response->setSuggestedFilename(data->m_suggestedFilename); 105 106 response->setHTTPStatusCode(data->m_httpStatusCode); 107 response->setHTTPStatusText(data->m_httpStatusText); 108 109 response->lazyInit(CommonAndUncommonFields); 110 response->m_httpHeaderFields.adopt(WTF::move(data->m_httpHeaders)); 111 response->m_resourceLoadTiming = data->m_resourceLoadTiming; 112 response->doPlatformAdopt(data); 113 return response.release(); 114} 115 116PassOwnPtr<CrossThreadResourceResponseData> ResourceResponseBase::copyData() const 117{ 118 OwnPtr<CrossThreadResourceResponseData> data = adoptPtr(new CrossThreadResourceResponseData); 119 data->m_url = url().copy(); 120 data->m_mimeType = mimeType().isolatedCopy(); 121 data->m_expectedContentLength = expectedContentLength(); 122 data->m_textEncodingName = textEncodingName().isolatedCopy(); 123 data->m_suggestedFilename = suggestedFilename().isolatedCopy(); 124 data->m_httpStatusCode = httpStatusCode(); 125 data->m_httpStatusText = httpStatusText().isolatedCopy(); 126 data->m_httpHeaders = httpHeaderFields().copyData(); 127 data->m_resourceLoadTiming = m_resourceLoadTiming; 128 return asResourceResponse().doPlatformCopyData(data.release()); 129} 130 131bool ResourceResponseBase::isHTTP() const 132{ 133 lazyInit(CommonFieldsOnly); 134 135 String protocol = m_url.protocol(); 136 137 return equalIgnoringCase(protocol, "http") || equalIgnoringCase(protocol, "https"); 138} 139 140const URL& ResourceResponseBase::url() const 141{ 142 lazyInit(CommonFieldsOnly); 143 144 return m_url; 145} 146 147void ResourceResponseBase::setURL(const URL& url) 148{ 149 lazyInit(CommonFieldsOnly); 150 m_isNull = false; 151 152 m_url = url; 153 154 // FIXME: Should invalidate or update platform response if present. 155} 156 157const String& ResourceResponseBase::mimeType() const 158{ 159 lazyInit(CommonFieldsOnly); 160 161 return m_mimeType; 162} 163 164void ResourceResponseBase::setMimeType(const String& mimeType) 165{ 166 lazyInit(CommonFieldsOnly); 167 m_isNull = false; 168 169 // FIXME: MIME type is determined by HTTP Content-Type header. We should update the header, so that it doesn't disagree with m_mimeType. 170 m_mimeType = mimeType; 171 172 // FIXME: Should invalidate or update platform response if present. 173} 174 175long long ResourceResponseBase::expectedContentLength() const 176{ 177 lazyInit(CommonFieldsOnly); 178 179 return m_expectedContentLength; 180} 181 182void ResourceResponseBase::setExpectedContentLength(long long expectedContentLength) 183{ 184 lazyInit(CommonFieldsOnly); 185 m_isNull = false; 186 187 // FIXME: Content length is determined by HTTP Content-Length header. We should update the header, so that it doesn't disagree with m_expectedContentLength. 188 m_expectedContentLength = expectedContentLength; 189 190 // FIXME: Should invalidate or update platform response if present. 191} 192 193const String& ResourceResponseBase::textEncodingName() const 194{ 195 lazyInit(CommonFieldsOnly); 196 197 return m_textEncodingName; 198} 199 200void ResourceResponseBase::setTextEncodingName(const String& encodingName) 201{ 202 lazyInit(CommonFieldsOnly); 203 m_isNull = false; 204 205 // FIXME: Text encoding is determined by HTTP Content-Type header. We should update the header, so that it doesn't disagree with m_textEncodingName. 206 m_textEncodingName = encodingName; 207 208 // FIXME: Should invalidate or update platform response if present. 209} 210 211// FIXME should compute this on the fly 212const String& ResourceResponseBase::suggestedFilename() const 213{ 214 lazyInit(AllFields); 215 216 return m_suggestedFilename; 217} 218 219void ResourceResponseBase::setSuggestedFilename(const String& suggestedName) 220{ 221 lazyInit(AllFields); 222 m_isNull = false; 223 224 // FIXME: Suggested file name is calculated based on other headers. There should not be a setter for it. 225 m_suggestedFilename = suggestedName; 226 227 // FIXME: Should invalidate or update platform response if present. 228} 229 230int ResourceResponseBase::httpStatusCode() const 231{ 232 lazyInit(CommonFieldsOnly); 233 234 return m_httpStatusCode; 235} 236 237void ResourceResponseBase::setHTTPStatusCode(int statusCode) 238{ 239 lazyInit(CommonFieldsOnly); 240 241 m_httpStatusCode = statusCode; 242 243 // FIXME: Should invalidate or update platform response if present. 244} 245 246const String& ResourceResponseBase::httpStatusText() const 247{ 248 lazyInit(CommonAndUncommonFields); 249 250 return m_httpStatusText; 251} 252 253void ResourceResponseBase::setHTTPStatusText(const String& statusText) 254{ 255 lazyInit(CommonAndUncommonFields); 256 257 m_httpStatusText = statusText; 258 259 // FIXME: Should invalidate or update platform response if present. 260} 261 262String ResourceResponseBase::httpHeaderField(const String& name) const 263{ 264 lazyInit(CommonFieldsOnly); 265 266 // If we already have the header, just return it instead of consuming memory by grabing all headers. 267 String value = m_httpHeaderFields.get(name); 268 if (!value.isEmpty()) 269 return value; 270 271 lazyInit(CommonAndUncommonFields); 272 273 return m_httpHeaderFields.get(name); 274} 275 276String ResourceResponseBase::httpHeaderField(HTTPHeaderName name) const 277{ 278 lazyInit(CommonFieldsOnly); 279 280 // If we already have the header, just return it instead of consuming memory by grabing all headers. 281 String value = m_httpHeaderFields.get(name); 282 if (!value.isEmpty()) 283 return value; 284 285 lazyInit(CommonAndUncommonFields); 286 287 return m_httpHeaderFields.get(name); 288} 289 290void ResourceResponseBase::updateHeaderParsedState(HTTPHeaderName name) 291{ 292 switch (name) { 293 case HTTPHeaderName::Age: 294 m_haveParsedAgeHeader = false; 295 break; 296 297 case HTTPHeaderName::CacheControl: 298 case HTTPHeaderName::Pragma: 299 m_haveParsedCacheControlHeader = false; 300 break; 301 302 case HTTPHeaderName::Date: 303 m_haveParsedDateHeader = false; 304 break; 305 306 case HTTPHeaderName::Expires: 307 m_haveParsedExpiresHeader = false; 308 break; 309 310 case HTTPHeaderName::LastModified: 311 m_haveParsedLastModifiedHeader = false; 312 break; 313 314 default: 315 break; 316 } 317} 318 319void ResourceResponseBase::setHTTPHeaderField(const String& name, const String& value) 320{ 321 lazyInit(CommonAndUncommonFields); 322 323 HTTPHeaderName headerName; 324 if (findHTTPHeaderName(name, headerName)) 325 updateHeaderParsedState(headerName); 326 327 m_httpHeaderFields.set(name, value); 328 329 // FIXME: Should invalidate or update platform response if present. 330} 331 332void ResourceResponseBase::setHTTPHeaderField(HTTPHeaderName name, const String& value) 333{ 334 lazyInit(CommonAndUncommonFields); 335 336 updateHeaderParsedState(name); 337 338 m_httpHeaderFields.set(name, value); 339 340 // FIXME: Should invalidate or update platform response if present. 341} 342 343void ResourceResponseBase::addHTTPHeaderField(const String& name, const String& value) 344{ 345 lazyInit(CommonAndUncommonFields); 346 347 HTTPHeaderName headerName; 348 if (findHTTPHeaderName(name, headerName)) 349 updateHeaderParsedState(headerName); 350 351 m_httpHeaderFields.add(name, value); 352} 353 354const HTTPHeaderMap& ResourceResponseBase::httpHeaderFields() const 355{ 356 lazyInit(CommonAndUncommonFields); 357 358 return m_httpHeaderFields; 359} 360 361void ResourceResponseBase::parseCacheControlDirectives() const 362{ 363 ASSERT(!m_haveParsedCacheControlHeader); 364 365 lazyInit(CommonFieldsOnly); 366 367 m_haveParsedCacheControlHeader = true; 368 369 m_cacheControlContainsMustRevalidate = false; 370 m_cacheControlContainsNoCache = false; 371 m_cacheControlMaxAge = std::numeric_limits<double>::quiet_NaN(); 372 373 String cacheControlValue = m_httpHeaderFields.get(HTTPHeaderName::CacheControl); 374 if (!cacheControlValue.isEmpty()) { 375 Vector<std::pair<String, String>> directives; 376 parseCacheHeader(cacheControlValue, directives); 377 378 size_t directivesSize = directives.size(); 379 for (size_t i = 0; i < directivesSize; ++i) { 380 // RFC2616 14.9.1: A no-cache directive with a value is only meaningful for proxy caches. 381 // It should be ignored by a browser level cache. 382 if (equalIgnoringCase(directives[i].first, "no-cache") && directives[i].second.isEmpty()) 383 m_cacheControlContainsNoCache = true; 384 else if (equalIgnoringCase(directives[i].first, "no-store")) 385 m_cacheControlContainsNoStore = true; 386 else if (equalIgnoringCase(directives[i].first, "must-revalidate")) 387 m_cacheControlContainsMustRevalidate = true; 388 else if (equalIgnoringCase(directives[i].first, "max-age")) { 389 if (!std::isnan(m_cacheControlMaxAge)) { 390 // First max-age directive wins if there are multiple ones. 391 continue; 392 } 393 bool ok; 394 double maxAge = directives[i].second.toDouble(&ok); 395 if (ok) 396 m_cacheControlMaxAge = maxAge; 397 } 398 } 399 } 400 401 if (!m_cacheControlContainsNoCache) { 402 // Handle Pragma: no-cache 403 // This is deprecated and equivalent to Cache-control: no-cache 404 // Don't bother tokenizing the value, it is not important 405 String pragmaValue = m_httpHeaderFields.get(HTTPHeaderName::Pragma); 406 407 m_cacheControlContainsNoCache = pragmaValue.contains("no-cache", false); 408 } 409} 410 411bool ResourceResponseBase::cacheControlContainsNoCache() const 412{ 413 if (!m_haveParsedCacheControlHeader) 414 parseCacheControlDirectives(); 415 return m_cacheControlContainsNoCache; 416} 417 418bool ResourceResponseBase::cacheControlContainsNoStore() const 419{ 420 if (!m_haveParsedCacheControlHeader) 421 parseCacheControlDirectives(); 422 return m_cacheControlContainsNoStore; 423} 424 425bool ResourceResponseBase::cacheControlContainsMustRevalidate() const 426{ 427 if (!m_haveParsedCacheControlHeader) 428 parseCacheControlDirectives(); 429 return m_cacheControlContainsMustRevalidate; 430} 431 432bool ResourceResponseBase::hasCacheValidatorFields() const 433{ 434 lazyInit(CommonFieldsOnly); 435 436 return !m_httpHeaderFields.get(HTTPHeaderName::LastModified).isEmpty() || !m_httpHeaderFields.get(HTTPHeaderName::ETag).isEmpty(); 437} 438 439double ResourceResponseBase::cacheControlMaxAge() const 440{ 441 if (!m_haveParsedCacheControlHeader) 442 parseCacheControlDirectives(); 443 return m_cacheControlMaxAge; 444} 445 446static double parseDateValueInHeader(const HTTPHeaderMap& headers, HTTPHeaderName headerName) 447{ 448 String headerValue = headers.get(headerName); 449 if (headerValue.isEmpty()) 450 return std::numeric_limits<double>::quiet_NaN(); 451 // This handles all date formats required by RFC2616: 452 // Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 453 // Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 454 // Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format 455 double dateInMilliseconds = parseDate(headerValue); 456 if (!std::isfinite(dateInMilliseconds)) 457 return std::numeric_limits<double>::quiet_NaN(); 458 return dateInMilliseconds / 1000; 459} 460 461double ResourceResponseBase::date() const 462{ 463 lazyInit(CommonFieldsOnly); 464 465 if (!m_haveParsedDateHeader) { 466 m_date = parseDateValueInHeader(m_httpHeaderFields, HTTPHeaderName::Date); 467 m_haveParsedDateHeader = true; 468 } 469 return m_date; 470} 471 472double ResourceResponseBase::age() const 473{ 474 lazyInit(CommonFieldsOnly); 475 476 if (!m_haveParsedAgeHeader) { 477 String headerValue = m_httpHeaderFields.get(HTTPHeaderName::Age); 478 bool ok; 479 m_age = headerValue.toDouble(&ok); 480 if (!ok) 481 m_age = std::numeric_limits<double>::quiet_NaN(); 482 m_haveParsedAgeHeader = true; 483 } 484 return m_age; 485} 486 487double ResourceResponseBase::expires() const 488{ 489 lazyInit(CommonFieldsOnly); 490 491 if (!m_haveParsedExpiresHeader) { 492 m_expires = parseDateValueInHeader(m_httpHeaderFields, HTTPHeaderName::Expires); 493 m_haveParsedExpiresHeader = true; 494 } 495 return m_expires; 496} 497 498double ResourceResponseBase::lastModified() const 499{ 500 lazyInit(CommonFieldsOnly); 501 502 if (!m_haveParsedLastModifiedHeader) { 503 m_lastModified = parseDateValueInHeader(m_httpHeaderFields, HTTPHeaderName::LastModified); 504 m_haveParsedLastModifiedHeader = true; 505 } 506 return m_lastModified; 507} 508 509bool ResourceResponseBase::isAttachment() const 510{ 511 lazyInit(CommonAndUncommonFields); 512 513 String value = m_httpHeaderFields.get(HTTPHeaderName::ContentDisposition); 514 size_t loc = value.find(';'); 515 if (loc != notFound) 516 value = value.left(loc); 517 value = value.stripWhiteSpace(); 518 519 return equalIgnoringCase(value, "attachment"); 520} 521 522bool ResourceResponseBase::wasCached() const 523{ 524 lazyInit(CommonAndUncommonFields); 525 526 return m_wasCached; 527} 528 529void ResourceResponseBase::setWasCached(bool value) 530{ 531 m_wasCached = value; 532} 533 534bool ResourceResponseBase::connectionReused() const 535{ 536 lazyInit(CommonAndUncommonFields); 537 538 return m_connectionReused; 539} 540 541void ResourceResponseBase::setConnectionReused(bool connectionReused) 542{ 543 lazyInit(CommonAndUncommonFields); 544 545 m_connectionReused = connectionReused; 546} 547 548unsigned ResourceResponseBase::connectionID() const 549{ 550 lazyInit(CommonAndUncommonFields); 551 552 return m_connectionID; 553} 554 555void ResourceResponseBase::setConnectionID(unsigned connectionID) 556{ 557 lazyInit(CommonAndUncommonFields); 558 559 m_connectionID = connectionID; 560} 561 562void ResourceResponseBase::lazyInit(InitLevel initLevel) const 563{ 564 const_cast<ResourceResponse*>(static_cast<const ResourceResponse*>(this))->platformLazyInit(initLevel); 565} 566 567bool ResourceResponseBase::compare(const ResourceResponse& a, const ResourceResponse& b) 568{ 569 if (a.isNull() != b.isNull()) 570 return false; 571 if (a.url() != b.url()) 572 return false; 573 if (a.mimeType() != b.mimeType()) 574 return false; 575 if (a.expectedContentLength() != b.expectedContentLength()) 576 return false; 577 if (a.textEncodingName() != b.textEncodingName()) 578 return false; 579 if (a.suggestedFilename() != b.suggestedFilename()) 580 return false; 581 if (a.httpStatusCode() != b.httpStatusCode()) 582 return false; 583 if (a.httpStatusText() != b.httpStatusText()) 584 return false; 585 if (a.httpHeaderFields() != b.httpHeaderFields()) 586 return false; 587 if (a.resourceLoadTiming() != b.resourceLoadTiming()) 588 return false; 589 return ResourceResponse::platformCompare(a, b); 590} 591 592static bool isCacheHeaderSeparator(UChar c) 593{ 594 // See RFC 2616, Section 2.2 595 switch (c) { 596 case '(': 597 case ')': 598 case '<': 599 case '>': 600 case '@': 601 case ',': 602 case ';': 603 case ':': 604 case '\\': 605 case '"': 606 case '/': 607 case '[': 608 case ']': 609 case '?': 610 case '=': 611 case '{': 612 case '}': 613 case ' ': 614 case '\t': 615 return true; 616 default: 617 return false; 618 } 619} 620 621static bool isControlCharacter(UChar c) 622{ 623 return c < ' ' || c == 127; 624} 625 626static inline String trimToNextSeparator(const String& str) 627{ 628 return str.substring(0, str.find(isCacheHeaderSeparator)); 629} 630 631static void parseCacheHeader(const String& header, Vector<std::pair<String, String>>& result) 632{ 633 const String safeHeader = header.removeCharacters(isControlCharacter); 634 unsigned max = safeHeader.length(); 635 for (unsigned pos = 0; pos < max; /* pos incremented in loop */) { 636 size_t nextCommaPosition = safeHeader.find(',', pos); 637 size_t nextEqualSignPosition = safeHeader.find('=', pos); 638 if (nextEqualSignPosition != notFound && (nextEqualSignPosition < nextCommaPosition || nextCommaPosition == notFound)) { 639 // Get directive name, parse right hand side of equal sign, then add to map 640 String directive = trimToNextSeparator(safeHeader.substring(pos, nextEqualSignPosition - pos).stripWhiteSpace()); 641 pos += nextEqualSignPosition - pos + 1; 642 643 String value = safeHeader.substring(pos, max - pos).stripWhiteSpace(); 644 if (value[0] == '"') { 645 // The value is a quoted string 646 size_t nextDoubleQuotePosition = value.find('"', 1); 647 if (nextDoubleQuotePosition != notFound) { 648 // Store the value as a quoted string without quotes 649 result.append(std::pair<String, String>(directive, value.substring(1, nextDoubleQuotePosition - 1).stripWhiteSpace())); 650 pos += (safeHeader.find('"', pos) - pos) + nextDoubleQuotePosition + 1; 651 // Move past next comma, if there is one 652 size_t nextCommaPosition2 = safeHeader.find(',', pos); 653 if (nextCommaPosition2 != notFound) 654 pos += nextCommaPosition2 - pos + 1; 655 else 656 return; // Parse error if there is anything left with no comma 657 } else { 658 // Parse error; just use the rest as the value 659 result.append(std::pair<String, String>(directive, trimToNextSeparator(value.substring(1, value.length() - 1).stripWhiteSpace()))); 660 return; 661 } 662 } else { 663 // The value is a token until the next comma 664 size_t nextCommaPosition2 = value.find(','); 665 if (nextCommaPosition2 != notFound) { 666 // The value is delimited by the next comma 667 result.append(std::pair<String, String>(directive, trimToNextSeparator(value.substring(0, nextCommaPosition2).stripWhiteSpace()))); 668 pos += (safeHeader.find(',', pos) - pos) + 1; 669 } else { 670 // The rest is the value; no change to value needed 671 result.append(std::pair<String, String>(directive, trimToNextSeparator(value))); 672 return; 673 } 674 } 675 } else if (nextCommaPosition != notFound && (nextCommaPosition < nextEqualSignPosition || nextEqualSignPosition == notFound)) { 676 // Add directive to map with empty string as value 677 result.append(std::pair<String, String>(trimToNextSeparator(safeHeader.substring(pos, nextCommaPosition - pos).stripWhiteSpace()), "")); 678 pos += nextCommaPosition - pos + 1; 679 } else { 680 // Add last directive to map with empty string as value 681 result.append(std::pair<String, String>(trimToNextSeparator(safeHeader.substring(pos, max - pos).stripWhiteSpace()), "")); 682 return; 683 } 684 } 685} 686 687} 688