From 645d0943d61885d714e39652b2af65cee4741d17 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 7 Jan 2013 16:30:55 -0500 Subject: [PATCH] soup_message_get_https_status: provide info for failed attempts too SoupMessage:tls-certificate and SoupMessage:tls-errors were only getting set for successful https connections. It is useful to have them be set on failed ones as well. Fix that, and make ssl-test test it. https://bugzilla.gnome.org/show_bug.cgi?id=690176 --- libsoup/soup-message.c | 10 ++++++---- libsoup/soup-session.c | 8 ++++---- tests/ssl-test.c | 4 ++++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/libsoup/soup-message.c b/libsoup/soup-message.c index 67b6e6f..750b992 100644 --- a/libsoup/soup-message.c +++ b/libsoup/soup-message.c @@ -1826,11 +1826,13 @@ soup_message_set_https_status (SoupMessage *msg, SoupConnection *conn) * @certificate: (out) (transfer none): @msg's TLS certificate * @errors: (out): the verification status of @certificate * - * If @msg is using https, this retrieves the #GTlsCertificate - * associated with its connection, and the #GTlsCertificateFlags showing - * what problems, if any, have been found with that certificate. + * If @msg is using https (or attempted to use https but got + * %SOUP_STATUS_SSL_FAILED), this retrieves the #GTlsCertificate + * associated with its connection, and the #GTlsCertificateFlags + * showing what problems, if any, have been found with that + * certificate. * - * Return value: %TRUE if @msg uses https, %FALSE if not + * Return value: %TRUE if @msg used/attempted https, %FALSE if not * * Since: 2.34 */ diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c index e37a71d..3b23846 100644 --- a/libsoup/soup-session.c +++ b/libsoup/soup-session.c @@ -1509,8 +1509,7 @@ tunnel_complete (SoupConnection *conn, guint status, gpointer user_data) if (item->msg->status_code) item->state = SOUP_MESSAGE_FINISHING; - else - soup_message_set_https_status (item->msg, item->conn); + soup_message_set_https_status (item->msg, item->conn); if (!SOUP_STATUS_IS_SUCCESSFUL (status)) { soup_connection_disconnect (conn); @@ -1597,6 +1596,8 @@ got_connection (SoupConnection *conn, guint status, gpointer user_data) SoupMessageQueueItem *item = user_data; SoupSession *session = item->session; + soup_message_set_https_status (item->msg, item->conn); + if (status != SOUP_STATUS_OK) { soup_connection_disconnect (conn); if (item->state == SOUP_MESSAGE_CONNECTING) { @@ -1751,10 +1752,10 @@ get_connection (SoupMessageQueueItem *item, gboolean *should_cleanup) } soup_session_set_item_connection (session, item, conn); - soup_message_set_https_status (item->msg, item->conn); if (soup_connection_get_state (item->conn) != SOUP_CONNECTION_NEW) { item->state = SOUP_MESSAGE_READY; + soup_message_set_https_status (item->msg, item->conn); return TRUE; } @@ -1801,7 +1802,6 @@ soup_session_process_queue_item (SoupSession *session, break; case SOUP_MESSAGE_READY: - soup_message_set_https_status (item->msg, item->conn); if (item->msg->status_code) { if (item->msg->status_code == SOUP_STATUS_TRY_AGAIN) { soup_message_cleanup_response (item->msg); diff --git a/tests/ssl-test.c b/tests/ssl-test.c index 6d96bc7..7716f30 100644 --- a/tests/ssl-test.c +++ b/tests/ssl-test.c @@ -109,6 +109,10 @@ do_one_strict_test (SoupSession *session, char *uri, errors++; } } + if (!soup_message_get_https_status (msg, NULL, NULL)) { + debug_printf (1, " get_https_status returns FALSE?\n"); + errors++; + } g_object_unref (msg); } -- 2.7.4