From ea0f5481f01eacedff264bf08144164aa989ec4d Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 5 May 2014 16:06:42 +0200 Subject: http: Add reference counting to the session object. * common/http.c (http_session_t): Add field "refcount". (_my_socket_new, _my_socket_ref, _my_socket_unref): Add debug code. (send_request, my_npth_read, my_npth_write): Use SOCK object for the transport ptr. (http_session_release): Factor all code out to ... (session_unref): here. Deref SOCK. (http_session_new): Init refcount and transport ptr. (http_session_ref): New. Ref and unref all assignments. -- Having the reference counted session objects makes it easier for the application to pass around only an estream. Without that the application would need to implement an es_onclose machinery for the session object. --- common/t-http.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'common/t-http.c') diff --git a/common/t-http.c b/common/t-http.c index 0191e8519..7b9c7446b 100644 --- a/common/t-http.c +++ b/common/t-http.c @@ -144,6 +144,7 @@ main (int argc, char **argv) int c; unsigned int my_http_flags = 0; int no_out = 0; + int tls_dbg = 0; const char *cafile = NULL; http_session_t session = NULL; @@ -163,12 +164,13 @@ main (int argc, char **argv) { fputs ("usage: " PGM " URL\n" "Options:\n" - " --verbose print timings etc.\n" - " --debug flyswatter\n" - " --cacert FNAME expect CA certificate in file FNAME\n" - " --no-verify do not verify the certificate\n" - " --force-tls use HTTP_FLAG_FORCE_TLS\n" - " --no-out do not print the content\n", + " --verbose print timings etc.\n" + " --debug flyswatter\n" + " --gnutls-debug N use GNUTLS debug level N\n" + " --cacert FNAME expect CA certificate in file FNAME\n" + " --no-verify do not verify the certificate\n" + " --force-tls use HTTP_FLAG_FORCE_TLS\n" + " --no-out do not print the content\n", stdout); exit (0); } @@ -183,6 +185,15 @@ main (int argc, char **argv) debug++; argc--; argv++; } + else if (!strcmp (*argv, "--gnutls-debug")) + { + argc--; argv++; + if (argc) + { + tls_dbg = atoi (*argv); + argc--; argv++; + } + } else if (!strcmp (*argv, "--cacert")) { argc--; argv++; @@ -248,7 +259,8 @@ main (int argc, char **argv) /* gnutls_certificate_set_dh_params (certcred, dh_params); */ gnutls_global_set_log_function (my_gnutls_log); - /* gnutls_global_set_log_level (2); */ + if (tls_dbg) + gnutls_global_set_log_level (tls_dbg); #endif /*HTTP_USE_GNUTLS*/ -- cgit v1.2.3