diff --git a/libsoup2.4/libsoup/soup-auth-manager.c b/libsoup2.4/libsoup/soup-auth-manager.c
index df8dddf..f29d820 100644
--- a/libsoup2.4/libsoup/soup-auth-manager.c
+++ b/libsoup2.4/libsoup/soup-auth-manager.c
@@ -245,7 +245,7 @@ extract_challenge (const char *challenges, const char *scheme)
 	for (i = items; i; i = i->next) {
 		item = i->data;
 		if (!g_ascii_strncasecmp (item, scheme, schemelen) &&
-		    g_ascii_isspace (item[schemelen]))
+		    (g_ascii_isspace (item[schemelen]) || item[schemelen] == '\0'))
 			break;
 	}
 	if (!i) {
diff --git a/libsoup2.4/libsoup/soup-auth.c b/libsoup2.4/libsoup/soup-auth.c
index dc855cc..67370fc 100644
--- a/libsoup2.4/libsoup/soup-auth.c
+++ b/libsoup2.4/libsoup/soup-auth.c
@@ -218,25 +218,18 @@ soup_auth_new (GType type, SoupMessage *msg, const char *auth_header)
 	}
 
 	params = soup_header_parse_param_list (auth_header + strlen (scheme));
-	if (!params) {
-		g_object_unref (auth);
-		return NULL;
+	if (params) {
+		realm = g_hash_table_lookup (params, "realm");
+		if (realm)
+			auth->realm = g_strdup (realm);
 	}
 
-	realm = g_hash_table_lookup (params, "realm");
-	if (!realm) {
-		soup_header_free_param_list (params);
-		g_object_unref (auth);
-		return NULL;
-	}
-
-	auth->realm = g_strdup (realm);
-
 	if (!SOUP_AUTH_GET_CLASS (auth)->update (auth, msg, params)) {
 		g_object_unref (auth);
 		auth = NULL;
 	}
-	soup_header_free_param_list (params);
+	if (params)
+		soup_header_free_param_list (params);
 	return auth;
 }
 
