aboutsummaryrefslogtreecommitdiffstats
path: root/common/t-http.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2014-05-05 14:06:42 +0000
committerWerner Koch <[email protected]>2014-05-05 14:06:42 +0000
commitea0f5481f01eacedff264bf08144164aa989ec4d (patch)
treed6d288d4a2576ab1ab477fd686eaa6d7d8ba3631 /common/t-http.c
parenthttp: Add HTTP_FLAG_FORCE_TLS and http_get_tls_info. (diff)
downloadgnupg-ea0f5481f01eacedff264bf08144164aa989ec4d.tar.gz
gnupg-ea0f5481f01eacedff264bf08144164aa989ec4d.zip
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.
Diffstat (limited to '')
-rw-r--r--common/t-http.c26
1 files changed, 19 insertions, 7 deletions
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*/