Skip to content
Permalink
Browse files
[curl] Merge http response header values
https://bugs.webkit.org/show_bug.cgi?id=117342

Patch by Peter Gal <galpeter@inf.u-szeged.hu> on 2013-06-13
Reviewed by Brent Fulgham.

According to the HTTP RFC some HTTP header values should be
merged if multiple entries for the same header exists.

* platform/network/curl/ResourceHandleManager.cpp:
(WebCore::isAppendableHeader):
(WebCore::headerCallback):

Canonical link: https://commits.webkit.org/135783@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@151580 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
elecro authored and webkit-commit-queue committed Jun 14, 2013
1 parent 5e27699 commit 804f3daca2a863407c2b202a799afee918ee72ce
Showing 2 changed files with 65 additions and 2 deletions.
@@ -1,3 +1,17 @@
2013-06-13 Peter Gal <galpeter@inf.u-szeged.hu>

[curl] Merge http response header values
https://bugs.webkit.org/show_bug.cgi?id=117342

Reviewed by Brent Fulgham.

According to the HTTP RFC some HTTP header values should be
merged if multiple entries for the same header exists.

* platform/network/curl/ResourceHandleManager.cpp:
(WebCore::isAppendableHeader):
(WebCore::headerCallback):

2013-06-13 Simon Fraser <simon.fraser@apple.com>

Should not call firePaintRelatedMilestones() for "update control tints" paint pass
@@ -236,6 +236,48 @@ static size_t writeCallback(void* ptr, size_t size, size_t nmemb, void* data)
return totalSize;
}

static bool isAppendableHeader(const String &key)
{
static const char* appendableHeaders[] = {
"access-control-allow-headers",
"access-control-allow-methods",
"access-control-allow-origin",
"access-control-expose-headers",
"allow",
"cache-control",
"connection",
"content-encoding",
"content-language",
"if-match",
"if-none-match",
"keep-alive",
"pragma",
"proxy-authenticate",
"public",
"server",
"te",
"trailer",
"transfer-encoding",
"upgrade",
"user-agent",
"vary",
"via",
"warning",
"www-authenticate",
0
};

// Custom headers start with 'X-', and need no further checking.
if (key.startsWith("x-", /* caseSensitive */ false))
return true;

for (unsigned i = 0; appendableHeaders[i]; ++i)
if (equalIgnoringCase(key, appendableHeaders[i]))
return true;

return false;
}

/*
* This is being called for each HTTP header in the response. This includes '\r\n'
* for the last line of the header.
@@ -316,8 +358,15 @@ static size_t headerCallback(char* ptr, size_t size, size_t nmemb, void* data)

} else {
int splitPos = header.find(":");
if (splitPos != -1)
d->m_response.setHTTPHeaderField(header.left(splitPos), header.substring(splitPos+1).stripWhiteSpace());
if (splitPos != -1) {
String key = header.left(splitPos).stripWhiteSpace();
String value = header.substring(splitPos + 1).stripWhiteSpace();

if (isAppendableHeader(key))
d->m_response.addHTTPHeaderField(key, value);
else
d->m_response.setHTTPHeaderField(key, value);
}
}

return totalSize;

0 comments on commit 804f3da

Please sign in to comment.