Make the glib-networking dependency more explicit
authorDan Winship <danw@gnome.org>
Wed, 2 Feb 2011 20:38:26 +0000 (15:38 -0500)
committerDan Winship <danw@gnome.org>
Wed, 2 Feb 2011 20:38:26 +0000 (15:38 -0500)
Require glib-networking to be present at build time (with an error
explaining that you can pass --disable-tls-check, but packagers should
make sure libsoup has a runtime dependency on glib-networking).

Also, if a TLS connection fails because of missing glib-networking,
mention that in the reason_phrase, as a last resort.

configure.ac
libsoup/soup-session.c

index 5a5621e..0302709 100644 (file)
@@ -218,12 +218,6 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
        done
 fi
 
-dnl ******************************
-dnl *** Stuff for regression tests
-dnl ******************************
-AC_MSG_NOTICE([checking for programs needed for regression tests])
-MISSING_REGRESSION_TEST_PACKAGES=""
-
 AC_MSG_CHECKING([for glib-networking (glib TLS implementation)])
 save_CFLAGS="$CFLAGS"
 save_LIBS="$LIBS"
@@ -237,6 +231,24 @@ AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <gio/gio.h>],
 CFLAGS="$save_CFLAGS"
 LIBS="$save_LIBS"
 AC_MSG_RESULT($have_glib_networking)
+
+AC_ARG_ENABLE(tls-check,
+             AS_HELP_STRING([--disable-tls-check], [Don't error out if glib-networking is unavailable]))
+if test "$enable_tls_check" != "no" -a "$have_glib_networking" = "no"; then
+       AC_MSG_ERROR([libsoup requires glib-networking for TLS support.
+
+If you are building a packge, you can pass --disable-tls-check to
+allow building libsoup anyway (since glib-networking is not actually
+required at compile time), but you should be sure to add a runtime
+dependency on it.])
+fi
+
+dnl ******************************
+dnl *** Stuff for regression tests
+dnl ******************************
+AC_MSG_NOTICE([checking for programs needed for regression tests])
+MISSING_REGRESSION_TEST_PACKAGES=""
+
 if test "$have_glib_networking" = "no"; then
         MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES glib-networking"
 fi
index fdc83ae..dcea224 100644 (file)
@@ -1461,10 +1461,20 @@ soup_session_set_item_status (SoupSession          *session,
                        g_free (msg);
                        break;
                }
-               /* else fall through */
+               soup_message_set_status (item->msg, status_code);
+               break;
+
+       case SOUP_STATUS_SSL_FAILED:
+               if (!g_tls_backend_supports_tls (g_tls_backend_get_default ())) {
+                       soup_message_set_status_full (item->msg, status_code,
+                                                     "TLS/SSL support not available; install glib-networking");
+               } else
+                       soup_message_set_status (item->msg, status_code);
+               break;
 
        default:
                soup_message_set_status (item->msg, status_code);
+               break;
        }
 }