Commit 732fcd4b authored by Carlos Garcia Campos's avatar Carlos Garcia Campos
Browse files

Use header fast paths internally whenever possible

parent 18ef5ed9
Pipeline #287793 passed with stages
in 7 minutes and 11 seconds
......@@ -14,6 +14,7 @@
#include "auth/soup-auth-digest-private.h"
#include "soup.h"
#include "soup-message-private.h"
#include "soup-message-headers-private.h"
#include "soup-uri-utils-private.h"
#ifdef G_OS_WIN32
......@@ -391,10 +392,10 @@ authentication_info_cb (SoupMessage *msg, gpointer data)
if (auth != soup_message_get_auth (msg))
return;
header = soup_message_headers_get_one (soup_message_get_response_headers (msg),
soup_auth_is_for_proxy (auth) ?
"Proxy-Authentication-Info" :
"Authentication-Info");
header = soup_message_headers_get_one_common (soup_message_get_response_headers (msg),
soup_auth_is_for_proxy (auth) ?
SOUP_HEADER_PROXY_AUTHENTICATION_INFO :
SOUP_HEADER_AUTHENTICATION_INFO);
g_return_if_fail (header != NULL);
auth_params = soup_header_parse_param_list (header);
......
......@@ -15,6 +15,7 @@
#include "soup.h"
#include "soup-connection-auth.h"
#include "soup-message-private.h"
#include "soup-message-headers-private.h"
#include "soup-path-map.h"
#include "soup-session-private.h"
#include "soup-session-feature-private.h"
......@@ -242,11 +243,11 @@ static inline const char *
auth_header_for_message (SoupMessage *msg)
{
if (soup_message_get_status (msg) == SOUP_STATUS_PROXY_UNAUTHORIZED) {
return soup_message_headers_get_list (soup_message_get_response_headers (msg),
"Proxy-Authenticate");
return soup_message_headers_get_list_common (soup_message_get_response_headers (msg),
SOUP_HEADER_PROXY_AUTHENTICATE);
} else {
return soup_message_headers_get_list (soup_message_get_response_headers (msg),
"WWW-Authenticate");
return soup_message_headers_get_list_common (soup_message_get_response_headers (msg),
SOUP_HEADER_WWW_AUTHENTICATE);
}
}
......@@ -442,11 +443,11 @@ make_auto_ntlm_auth (SoupAuthManagerPrivate *priv, SoupAuthHost *host)
static void
update_authorization_header (SoupMessage *msg, SoupAuth *auth, gboolean is_proxy)
{
const char *authorization_header = is_proxy ? "Proxy-Authorization" : "Authorization";
SoupHeaderName authorization_header = is_proxy ? SOUP_HEADER_PROXY_AUTHORIZATION : SOUP_HEADER_AUTHORIZATION;
char *token;
if (soup_message_get_auth (msg))
soup_message_headers_remove (soup_message_get_request_headers (msg), authorization_header);
soup_message_headers_remove_common (soup_message_get_request_headers (msg), authorization_header);
if (!auth)
return;
......@@ -455,7 +456,7 @@ update_authorization_header (SoupMessage *msg, SoupAuth *auth, gboolean is_proxy
if (!token)
return;
soup_message_headers_replace (soup_message_get_request_headers (msg), authorization_header, token);
soup_message_headers_replace_common (soup_message_get_request_headers (msg), authorization_header, token);
g_free (token);
}
......
......@@ -20,6 +20,7 @@
#include "soup-headers.h"
#include "soup-message.h"
#include "soup-message-private.h"
#include "soup-message-headers-private.h"
#include "soup-misc.h"
#include "soup-uri-utils-private.h"
......@@ -357,8 +358,8 @@ check_server_response (SoupMessage *msg, gpointer auth)
return;
/* FIXME: need to check for proxy-auth too */
auth_headers = soup_message_headers_get_one (soup_message_get_response_headers (msg),
"WWW-Authenticate");
auth_headers = soup_message_headers_get_one_common (soup_message_get_response_headers (msg),
SOUP_HEADER_WWW_AUTHENTICATE);
if (!auth_headers || g_ascii_strncasecmp (auth_headers, "Negotiate ", 10) != 0) {
g_warning ("Failed to parse auth header");
conn->state = SOUP_NEGOTIATE_FAILED;
......
......@@ -19,6 +19,7 @@
#include "soup-auth-ntlm.h"
#include "soup.h"
#include "soup-message-private.h"
#include "soup-message-headers-private.h"
static void soup_ntlm_lanmanager_hash (const char *password,
guchar hash[21]);
......@@ -326,8 +327,8 @@ soup_auth_ntlm_update_connection (SoupConnectionAuth *auth, SoupMessage *msg,
*/
conn->state = SOUP_NTLM_FAILED;
if (soup_message_is_keepalive (msg)) {
soup_message_headers_append (soup_message_get_response_headers (msg),
"Connection", "close");
soup_message_headers_append_common (soup_message_get_response_headers (msg),
SOUP_HEADER_CONNECTION, "close");
}
return TRUE;
}
......
......@@ -39,6 +39,7 @@
#include "soup-cache-private.h"
#include "soup-content-processor.h"
#include "soup-message-private.h"
#include "soup-message-headers-private.h"
#include "soup.h"
#include "soup-message-metrics-private.h"
#include "soup-misc.h"
......@@ -184,7 +185,7 @@ get_cacheability (SoupCache *cache, SoupMessage *msg)
if (content_type && !g_ascii_strcasecmp (content_type, "multipart/x-mixed-replace"))
return SOUP_CACHE_UNCACHEABLE;
cache_control = soup_message_headers_get_list (soup_message_get_response_headers (msg), "Cache-Control");
cache_control = soup_message_headers_get_list_common (soup_message_get_response_headers (msg), SOUP_HEADER_CACHE_CONTROL);
if (cache_control && *cache_control) {
GHashTable *hash;
......@@ -222,7 +223,7 @@ get_cacheability (SoupCache *cache, SoupMessage *msg)
/* Section 13.9 */
if ((g_uri_get_query (soup_message_get_uri (msg))) &&
!soup_message_headers_get_one (soup_message_get_response_headers (msg), "Expires") &&
!soup_message_headers_get_one_common (soup_message_get_response_headers (msg), SOUP_HEADER_EXPIRES) &&
!has_max_age)
return SOUP_CACHE_UNCACHEABLE;
......@@ -307,7 +308,16 @@ remove_headers (const char *name, const char *value, SoupMessageHeaders *headers
soup_message_headers_remove (headers, name);
}
static char *hop_by_hop_headers[] = {"Connection", "Keep-Alive", "Proxy-Authenticate", "Proxy-Authorization", "TE", "Trailer", "Transfer-Encoding", "Upgrade"};
static SoupHeaderName hop_by_hop_headers[] = {
SOUP_HEADER_CONNECTION,
SOUP_HEADER_KEEP_ALIVE,
SOUP_HEADER_PROXY_AUTHENTICATE,
SOUP_HEADER_PROXY_AUTHORIZATION,
SOUP_HEADER_TE,
SOUP_HEADER_TRAILER,
SOUP_HEADER_TRANSFER_ENCODING,
SOUP_HEADER_UPGRADE
};
static void
copy_end_to_end_headers (SoupMessageHeaders *source, SoupMessageHeaders *destination)
......@@ -316,7 +326,7 @@ copy_end_to_end_headers (SoupMessageHeaders *source, SoupMessageHeaders *destina
soup_message_headers_foreach (source, (SoupMessageHeadersForeachFunc) copy_headers, destination);
for (i = 0; i < G_N_ELEMENTS (hop_by_hop_headers); i++)
soup_message_headers_remove (destination, hop_by_hop_headers[i]);
soup_message_headers_remove_common (destination, hop_by_hop_headers[i]);
soup_message_headers_clean_connection_headers (destination);
}
......@@ -355,7 +365,7 @@ soup_cache_entry_set_freshness (SoupCacheEntry *entry, SoupMessage *msg, SoupCac
entry->must_revalidate = FALSE;
entry->freshness_lifetime = 0;
cache_control = soup_message_headers_get_list (entry->headers, "Cache-Control");
cache_control = soup_message_headers_get_list_common (entry->headers, SOUP_HEADER_CACHE_CONTROL);
if (cache_control && *cache_control) {
const char *max_age, *s_maxage;
gint64 freshness_lifetime = 0;
......@@ -398,8 +408,8 @@ soup_cache_entry_set_freshness (SoupCacheEntry *entry, SoupMessage *msg, SoupCac
/* If the 'Expires' response header is present, use its value
* minus the value of the 'Date' response header
*/
expires = soup_message_headers_get_one (entry->headers, "Expires");
date = soup_message_headers_get_one (entry->headers, "Date");
expires = soup_message_headers_get_one_common (entry->headers, SOUP_HEADER_EXPIRES);
date = soup_message_headers_get_one_common (entry->headers, SOUP_HEADER_DATE);
if (expires && date) {
GDateTime *expires_d, *date_d;
time_t expires_t, date_t;
......@@ -443,7 +453,7 @@ soup_cache_entry_set_freshness (SoupCacheEntry *entry, SoupMessage *msg, SoupCac
than 24h (section 2.3.1.1) when using heuristics */
/* Last-Modified based heuristic */
last_modified = soup_message_headers_get_one (entry->headers, "Last-Modified");
last_modified = soup_message_headers_get_one_common (entry->headers, SOUP_HEADER_LAST_MODIFIED);
if (last_modified) {
GDateTime *soup_date;
time_t now, last_modified_t;
......@@ -489,7 +499,7 @@ soup_cache_entry_new (SoupCache *cache, SoupMessage *msg, time_t request_time, t
soup_cache_entry_set_freshness (entry, msg, cache);
/* Section 2.3.2, Calculating Age */
date = soup_message_headers_get_one (entry->headers, "Date");
date = soup_message_headers_get_one_common (entry->headers, SOUP_HEADER_DATE);
if (date) {
GDateTime *soup_date;
......@@ -500,7 +510,7 @@ soup_cache_entry_new (SoupCache *cache, SoupMessage *msg, time_t request_time, t
date_value = g_date_time_to_unix (soup_date);
g_date_time_unref (soup_date);
age = soup_message_headers_get_one (entry->headers, "Age");
age = soup_message_headers_get_one_common (entry->headers, SOUP_HEADER_AGE);
if (age)
age_value = g_ascii_strtoll (age, NULL, 10);
......@@ -1145,8 +1155,8 @@ soup_cache_has_response (SoupCache *cache, SoupMessage *msg)
/* 4. The request is a conditional request issued by the client.
*/
if (soup_message_headers_get_one (soup_message_get_request_headers (msg), "If-Modified-Since") ||
soup_message_headers_get_list (soup_message_get_request_headers (msg), "If-None-Match"))
if (soup_message_headers_get_one_common (soup_message_get_request_headers (msg), SOUP_HEADER_IF_MODIFIED_SINCE) ||
soup_message_headers_get_list_common (soup_message_get_request_headers (msg), SOUP_HEADER_IF_NONE_MATCH))
return SOUP_CACHE_RESPONSE_STALE;
/* 5. The presented request and stored response are free from
......@@ -1157,10 +1167,10 @@ soup_cache_has_response (SoupCache *cache, SoupMessage *msg)
/* For HTTP 1.0 compatibility. RFC2616 section 14.9.4
*/
if (soup_message_headers_header_contains (soup_message_get_request_headers (msg), "Pragma", "no-cache"))
if (soup_message_headers_header_contains_common (soup_message_get_request_headers (msg), SOUP_HEADER_PRAGMA, "no-cache"))
return SOUP_CACHE_RESPONSE_STALE;
cache_control = soup_message_headers_get_list (soup_message_get_request_headers (msg), "Cache-Control");
cache_control = soup_message_headers_get_list_common (soup_message_get_request_headers (msg), SOUP_HEADER_CACHE_CONTROL);
if (cache_control && *cache_control) {
GHashTable *hash = soup_header_parse_param_list (cache_control);
......@@ -1391,8 +1401,8 @@ soup_cache_generate_conditional_request (SoupCache *cache, SoupMessage *original
entry = soup_cache_entry_lookup (cache, original);
g_return_val_if_fail (entry, NULL);
last_modified = soup_message_headers_get_one (entry->headers, "Last-Modified");
etag = soup_message_headers_get_one (entry->headers, "ETag");
last_modified = soup_message_headers_get_one_common (entry->headers, SOUP_HEADER_LAST_MODIFIED);
etag = soup_message_headers_get_one_common (entry->headers, SOUP_HEADER_ETAG);
if (!last_modified && !etag)
return NULL;
......@@ -1415,13 +1425,13 @@ soup_cache_generate_conditional_request (SoupCache *cache, SoupMessage *original
g_list_free (disabled_features);
if (last_modified)
soup_message_headers_append (soup_message_get_request_headers (msg),
"If-Modified-Since",
last_modified);
soup_message_headers_append_common (soup_message_get_request_headers (msg),
SOUP_HEADER_IF_MODIFIED_SINCE,
last_modified);
if (etag)
soup_message_headers_append (soup_message_get_request_headers (msg),
"If-None-Match",
etag);
soup_message_headers_append_common (soup_message_get_request_headers (msg),
SOUP_HEADER_IF_NONE_MATCH,
etag);
return msg;
}
......
......@@ -13,6 +13,7 @@
#include "soup-converter-wrapper.h"
#include "soup-session-feature-private.h"
#include "soup-message-private.h"
#include "soup-message-headers-private.h"
#include "soup-headers.h"
#include "soup-uri-utils-private.h"
#ifdef WITH_BROTLI
......@@ -86,8 +87,8 @@ soup_content_decoder_get_decoders_for_msg (SoupContentDecoder *decoder, SoupMess
SoupContentDecoderCreator converter_creator;
GConverter *converter;
header = soup_message_headers_get_list (soup_message_get_response_headers (msg),
"Content-Encoding");
header = soup_message_headers_get_list_common (soup_message_get_response_headers (msg),
SOUP_HEADER_CONTENT_ENCODING);
if (!header)
return NULL;
......@@ -239,8 +240,8 @@ static void
soup_content_decoder_request_queued (SoupSessionFeature *feature,
SoupMessage *msg)
{
if (!soup_message_headers_get_one (soup_message_get_request_headers (msg),
"Accept-Encoding")) {
if (!soup_message_headers_get_one_common (soup_message_get_request_headers (msg),
SOUP_HEADER_ACCEPT_ENCODING)) {
const char *header = "gzip, deflate";
#ifdef WITH_BROTLI
......@@ -253,9 +254,8 @@ soup_content_decoder_request_queued (SoupSessionFeature *feature,
header = "gzip, deflate, br";
#endif
soup_message_headers_append (soup_message_get_request_headers (msg),
"Accept-Encoding",
header);
soup_message_headers_append_common (soup_message_get_request_headers (msg),
SOUP_HEADER_ACCEPT_ENCODING, header);
}
}
......
......@@ -20,6 +20,7 @@
#include "soup-content-processor.h"
#include "soup-content-sniffer-stream.h"
#include "soup-message-private.h"
#include "soup-message-headers-private.h"
#include "soup-session-feature-private.h"
/**
......@@ -807,7 +808,7 @@ soup_content_sniffer_sniff (SoupContentSniffer *sniffer, SoupMessage *msg,
/* MIMESNIFF: 7 Determining the sniffed MIME type of a resource. */
x_content_type_options = soup_message_headers_get_one (soup_message_get_response_headers (msg), "X-Content-Type-Options");
x_content_type_options = soup_message_headers_get_one_common (soup_message_get_response_headers (msg), SOUP_HEADER_X_CONTENT_TYPE_OPTIONS);
if (!g_strcmp0 (x_content_type_options, "nosniff"))
no_sniff = TRUE;
......
......@@ -14,6 +14,7 @@
#include "soup-cookie-jar.h"
#include "soup-date-utils-private.h"
#include "soup-message-private.h"
#include "soup-message-headers-private.h"
#include "soup-misc.h"
#include "soup.h"
#include "soup-session-feature-private.h"
......@@ -814,11 +815,11 @@ msg_starting_cb (SoupMessage *msg, gpointer feature)
soup_message_get_is_top_level_navigation (msg));
if (cookies != NULL) {
char *cookie_header = soup_cookies_to_cookie_header (cookies);
soup_message_headers_replace (soup_message_get_request_headers (msg), "Cookie", cookie_header);
soup_message_headers_replace_common (soup_message_get_request_headers (msg), SOUP_HEADER_COOKIE, cookie_header);
g_free (cookie_header);
g_slist_free_full (cookies, (GDestroyNotify)soup_cookie_free);
} else {
soup_message_headers_remove (soup_message_get_request_headers (msg), "Cookie");
soup_message_headers_remove_common (soup_message_get_request_headers (msg), SOUP_HEADER_COOKIE);
}
}
......
......@@ -14,6 +14,7 @@
#include "soup-cookie.h"
#include "soup-date-utils-private.h"
#include "soup-message-headers-private.h"
#include "soup-misc.h"
#include "soup-uri-utils-private.h"
#include "soup.h"
......@@ -931,7 +932,7 @@ soup_cookies_from_request (SoupMessage *msg)
gpointer name, value;
const char *header;
header = soup_message_headers_get_one (soup_message_get_request_headers (msg), "Cookie");
header = soup_message_headers_get_one_common (soup_message_get_request_headers (msg), SOUP_HEADER_COOKIE);
if (!header)
return NULL;
......@@ -967,8 +968,8 @@ soup_cookies_to_response (GSList *cookies, SoupMessage *msg)
header = g_string_new (NULL);
while (cookies) {
serialize_cookie (cookies->data, header, TRUE);
soup_message_headers_append (soup_message_get_response_headers (msg),
"Set-Cookie", header->str);
soup_message_headers_append_common (soup_message_get_response_headers (msg),
SOUP_HEADER_SET_COOKIE, header->str);
g_string_truncate (header, 0);
cookies = cookies->next;
}
......@@ -992,14 +993,14 @@ soup_cookies_to_request (GSList *cookies, SoupMessage *msg)
{
GString *header;
header = g_string_new (soup_message_headers_get_one (soup_message_get_request_headers (msg),
"Cookie"));
header = g_string_new (soup_message_headers_get_one_common (soup_message_get_request_headers (msg),
SOUP_HEADER_COOKIE));
while (cookies) {
serialize_cookie (cookies->data, header, FALSE);
cookies = cookies->next;
}
soup_message_headers_replace (soup_message_get_request_headers (msg),
"Cookie", header->str);
soup_message_headers_replace_common (soup_message_get_request_headers (msg),
SOUP_HEADER_COOKIE, header->str);
g_string_free (header, TRUE);
}
......
......@@ -25,6 +25,7 @@
#include "soup-filter-input-stream.h"
#include "soup-logger-private.h"
#include "soup-message-private.h"
#include "soup-message-headers-private.h"
#include "soup-message-metrics-private.h"
#include "soup-message-queue-item.h"
#include "soup-misc.h"
......@@ -550,8 +551,8 @@ io_read (SoupClientMessageIOHTTP1 *client_io,
* reading, and make sure the connection gets
* closed when we're done.
*/
soup_message_headers_append (soup_message_get_request_headers (msg),
"Connection", "close");
soup_message_headers_append_common (soup_message_get_request_headers (msg),
SOUP_HEADER_CONNECTION, "close");
soup_message_set_metrics_timestamp (msg, SOUP_MESSAGE_METRICS_RESPONSE_END);
io->read_state = SOUP_MESSAGE_IO_STATE_FINISHING;
break;
......@@ -763,10 +764,10 @@ io_run_until (SoupClientMessageIOHTTP1 *client_io,
io->write_state == SOUP_MESSAGE_IO_STATE_DONE) {
GUri *uri = soup_message_get_uri (msg);
char *uri_str = g_uri_to_string_partial (uri, G_URI_HIDE_PASSWORD);
const gchar *last_modified = soup_message_headers_get_one (soup_message_get_response_headers (msg), "Last-Modified");
const gchar *etag = soup_message_headers_get_one (soup_message_get_response_headers (msg), "ETag");
const gchar *if_modified_since = soup_message_headers_get_one (soup_message_get_request_headers (msg), "If-Modified-Since");
const gchar *if_none_match = soup_message_headers_get_one (soup_message_get_request_headers (msg), "If-None-Match");
const gchar *last_modified = soup_message_headers_get_one_common (soup_message_get_response_headers (msg), SOUP_HEADER_LAST_MODIFIED);
const gchar *etag = soup_message_headers_get_one_common (soup_message_get_response_headers (msg), SOUP_HEADER_ETAG);
const gchar *if_modified_since = soup_message_headers_get_one_common (soup_message_get_request_headers (msg), SOUP_HEADER_IF_MODIFIED_SINCE);
const gchar *if_none_match = soup_message_headers_get_one_common (soup_message_get_request_headers (msg), SOUP_HEADER_IF_NONE_MATCH);
/* FIXME: Expand and generalise sysprof support:
* https://gitlab.gnome.org/GNOME/sysprof/-/issues/43 */
......
......@@ -12,6 +12,7 @@
#include <string.h>
#include "soup-auth-domain-basic.h"
#include "soup-message-headers-private.h"
#include "soup.h"
/**
......@@ -292,8 +293,8 @@ soup_auth_domain_basic_check_password (SoupAuthDomain *domain,
char *msg_username, *msg_password;
gboolean ok;
header = soup_message_headers_get_one (soup_server_message_get_request_headers (msg),
"Authorization");
header = soup_message_headers_get_one_common (soup_server_message_get_request_headers (msg),
SOUP_HEADER_AUTHORIZATION);
if (!parse_basic (header, &msg_username, &msg_password))
return FALSE;
......
......@@ -14,6 +14,7 @@
#include "soup-auth-domain-digest.h"
#include "soup-uri-utils-private.h"
#include "soup-message-headers-private.h"
#include "soup.h"
#include "auth/soup-auth-digest-private.h"
......@@ -391,8 +392,8 @@ soup_auth_domain_digest_check_password (SoupAuthDomain *domain,
char hex_urp[33];
gboolean accept;
header = soup_message_headers_get_one (soup_server_message_get_request_headers (msg),
"Authorization");
header = soup_message_headers_get_one_common (soup_server_message_get_request_headers (msg),
SOUP_HEADER_AUTHORIZATION);
if (!header || (strncmp (header, "Digest ", 7) != 0))
return FALSE;
......
......@@ -12,6 +12,7 @@
#include <string.h>
#include "soup-auth-domain.h"
#include "soup-message-headers-private.h"
#include "soup.h"
#include "soup-path-map.h"
......@@ -539,10 +540,10 @@ soup_auth_domain_accepts (SoupAuthDomain *domain,
SoupAuthDomainPrivate *priv = soup_auth_domain_get_instance_private (domain);
const char *header;
header = soup_message_headers_get_one (soup_server_message_get_request_headers (msg),
priv->proxy ?
"Proxy-Authorization" :
"Authorization");
header = soup_message_headers_get_one_common (soup_server_message_get_request_headers (msg),
priv->proxy ?
SOUP_HEADER_PROXY_AUTHORIZATION :
SOUP_HEADER_AUTHORIZATION);
if (!header)
return NULL;
return SOUP_AUTH_DOMAIN_GET_CLASS (domain)->accepts (domain, msg, header);
......@@ -572,10 +573,10 @@ soup_auth_domain_challenge (SoupAuthDomain *domain,
SOUP_STATUS_PROXY_UNAUTHORIZED :
SOUP_STATUS_UNAUTHORIZED,
NULL);
soup_message_headers_append (soup_server_message_get_response_headers (msg),
priv->proxy ?
"Proxy-Authenticate" :
"WWW-Authenticate",
challenge);
soup_message_headers_append_common (soup_server_message_get_response_headers (msg),
priv->proxy ?
SOUP_HEADER_PROXY_AUTHENTICATE :
SOUP_HEADER_WWW_AUTHENTICATE,
challenge);
g_free (challenge);
}
......@@ -16,6 +16,7 @@
#include "soup-body-output-stream.h"
#include "soup-filter-input-stream.h"
#include "soup-server-message-private.h"
#include "soup-message-headers-private.h"
#include "soup-misc.h"
#include "soup-socket.h"
......@@ -244,14 +245,13 @@ handle_partial_get (SoupServerMessage *msg)
*/
multipart = soup_multipart_new ("multipart/byteranges");
content_type = soup_message_headers_get_one (response_headers,
"Content-Type");
content_type = soup_message_headers_get_one_common (response_headers, SOUP_HEADER_CONTENT_TYPE);
for (i = 0; i < nranges; i++) {
part_headers = soup_message_headers_new (SOUP_MESSAGE_HEADERS_MULTIPART);
if (content_type) {
soup_message_headers_append (part_headers,
"Content-Type",
content_type);
soup_message_headers_append_common (part_headers,
SOUP_HEADER_CONTENT_TYPE,
content_type);
}
soup_message_headers_set_content_range (part_headers,
ranges[i].start,
......@@ -584,14 +584,14 @@ parse_headers (SoupServerMessage *msg,
/* Handle request body encoding */
*encoding = soup_message_headers_get_encoding (request_headers);
if (*encoding == SOUP_ENCODING_UNRECOGNIZED) {
if (soup_message_headers_get_list (request_headers, "Transfer-Encoding"))
if (soup_message_headers_get_list_common (request_headers, SOUP_HEADER_TRANSFER_ENCODING))
return SOUP_STATUS_NOT_IMPLEMENTED;
else
return SOUP_STATUS_BAD_REQUEST;
}
/* Generate correct context for request */
req_host = soup_message_headers_get_one (request_headers, "Host");
req_host = soup_message_headers_get_one_common (request_headers, SOUP_HEADER_HOST);
if (req_host && strchr (req_host, '/')) {
g_free (req_path);
return SOUP_STATUS_BAD_REQUEST;
......@@ -691,7 +691,7 @@ io_read (SoupServerMessage *msg,
* closed when we're done.
*/
soup_server_message_set_status (msg, status, NULL);
soup_message_headers_append (request_headers, "Connection", "close");
soup_message_headers_append_common (request_headers, SOUP_HEADER_CONNECTION, "close");
io->read_state = SOUP_MESSAGE_IO_STATE_FINISHING;
break;
}
......
......@@ -14,6 +14,7 @@
#include "soup.h"
#include "soup-connection.h"
#include "soup-server-message-private.h"
#include "soup-message-headers-private.h"
#include "soup-socket.h"
#include "soup-uri-utils-private.h"
......@@ -384,15 +385,18 @@ soup_server_message_is_keepalive (SoupServerMessage *msg)
* doesn't request it. So ignore c_conn.
*/
if (!soup_message_headers_header_contains (msg->response_headers,
"Connection", "Keep-Alive"))
if (!soup_message_headers_header_contains_common (msg->response_headers,
SOUP_HEADER_CONNECTION,
"Keep-Alive"))
return FALSE;
} else {
/* Normally persistent unless either side requested otherwise */
if (soup_message_headers_header_contains (msg->request_headers,
"Connection", "close") ||
soup_message_headers_header_contains (msg->response_headers,
"Connection", "close"))
if (soup_message_headers_header_contains_common (msg->request_headers,
SOUP_HEADER_CONNECTION,
"close") ||
soup_message_headers_header_contains_common (msg->response_headers,
SOUP_HEADER_CONNECTION,
"close"))
return FALSE;
return TRUE;
......@@ -726,13 +730,14 @@ soup_server_message_set_response (SoupServerMessage *msg,
if (content_type) {
g_warn_if_fail (strchr (content_type, '/') != NULL);
soup_message_headers_replace (msg->response_headers,
"Content-Type", content_type);
soup_message_headers_replace_common (msg->response_headers,
SOUP_HEADER_CONTENT_TYPE,
content_type);
soup_message_body_append (msg->response_body, resp_use,
resp_body, resp_length);
} else {
soup_message_headers_remove (msg->response_headers,
"Content-Type");
soup_message_headers_remove_common (msg->response_headers,
SOUP_HEADER_CONTENT_TYPE);
soup_message_body_truncate (msg->response_body);
}
}
......@@ -767,8 +772,8 @@ soup_server_message_set_redirect (SoupServerMessage *msg,
</