soup_message_get_https_status: provide info for failed attempts too
authorDan Winship <danw@gnome.org>
Mon, 7 Jan 2013 21:30:55 +0000 (16:30 -0500)
committerDan Winship <danw@gnome.org>
Mon, 7 Jan 2013 21:30:55 +0000 (16:30 -0500)
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
libsoup/soup-session.c
tests/ssl-test.c

index 67b6e6f..750b992 100644 (file)
@@ -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
  */
index e37a71d..3b23846 100644 (file)
@@ -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);
index 6d96bc7..7716f30 100644 (file)
@@ -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);
 }