[GTK] Add webkit_uri_response_get_http_headers to WebKit2 GTK+ API
[WebKit-https.git] / Source / WebCore / platform / network / soup / ResourceResponseSoup.cpp
index cf8e33f..4947742 100644 (file)
 
 namespace WebCore {
 
+void ResourceResponse::updateSoupMessageHeaders(SoupMessageHeaders* soupHeaders) const
+{
+    for (const auto& header : httpHeaderFields())
+        soup_message_headers_append(soupHeaders, header.key.utf8().data(), header.value.utf8().data());
+}
+
 SoupMessage* ResourceResponse::toSoupMessage() const
 {
     // This GET here is just because SoupMessage wants it, we dn't really know.
@@ -42,13 +48,7 @@ SoupMessage* ResourceResponse::toSoupMessage() const
 
     soupMessage->status_code = httpStatusCode();
 
-    const HTTPHeaderMap& headers = httpHeaderFields();
-    SoupMessageHeaders* soupHeaders = soupMessage->response_headers;
-    if (!headers.isEmpty()) {
-        HTTPHeaderMap::const_iterator end = headers.end();
-        for (HTTPHeaderMap::const_iterator it = headers.begin(); it != end; ++it)
-            soup_message_headers_append(soupHeaders, it->key.utf8().data(), it->value.utf8().data());
-    }
+    updateSoupMessageHeaders(soupMessage->response_headers);
 
     soup_message_set_flags(soupMessage, m_soupFlags);