From 9bec4d23fc3a703a647f04f7725044fc5760d808 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 3 Oct 2002 16:46:00 +0000 Subject: [PATCH] show ssl error messages even in NDEBUG mode --- panda/src/downloader/httpClient.cxx | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/panda/src/downloader/httpClient.cxx b/panda/src/downloader/httpClient.cxx index fe1ff0783f..1c3bd1de5e 100644 --- a/panda/src/downloader/httpClient.cxx +++ b/panda/src/downloader/httpClient.cxx @@ -25,8 +25,10 @@ #ifdef HAVE_SSL +#define REPORT_SSL_ERRORS 1 + #include -#ifndef NDEBUG +#ifdef REPORT_SSL_ERRORS #include #endif @@ -148,7 +150,7 @@ load_certificates(const Filename &filename) { if (result <= 0) { downloader_cat.info() << "Could not load certificates from " << filename << ".\n"; -#ifndef NDEBUG +#ifdef REPORT_SSL_ERRORS ERR_print_errors_fp(stderr); #endif return false; @@ -298,7 +300,7 @@ make_ctx() { //////////////////////////////////////////////////////////////////// void HTTPClient:: initialize_ssl() { -#ifndef NDEBUG +#ifdef REPORT_SSL_ERRORS ERR_load_crypto_strings(); ERR_load_SSL_strings(); #endif @@ -423,7 +425,7 @@ get_http(const string &method, const URLSpec &url, const string &body) { if (BIO_do_connect(bio) <= 0) { downloader_cat.info() << "Could not contact server " << server_str << "\n"; -#ifndef NDEBUG +#ifdef REPORT_SSL_ERRORS ERR_print_errors_fp(stderr); #endif return NULL; @@ -453,7 +455,7 @@ get_https(const string &method, const URLSpec &url, const string &body) { if (BIO_do_connect(bio) <= 0) { downloader_cat.info() << "Could not contact server " << server_str << "\n"; -#ifndef NDEBUG +#ifdef REPORT_SSL_ERRORS ERR_print_errors_fp(stderr); #endif return NULL; @@ -488,7 +490,7 @@ get_http_proxy(const string &method, const URLSpec &url, const string &body) { if (BIO_do_connect(bio) <= 0) { downloader_cat.info() << "Could not contact proxy " << proxy_server_str << "\n"; -#ifndef NDEBUG +#ifdef REPORT_SSL_ERRORS ERR_print_errors_fp(stderr); #endif return NULL; @@ -520,7 +522,7 @@ get_https_proxy(const string &method, const URLSpec &url, const string &body) { if (BIO_do_connect(bio) <= 0) { downloader_cat.info() << "Could not contact proxy " << proxy_server_str << "\n"; -#ifndef NDEBUG +#ifdef REPORT_SSL_ERRORS ERR_print_errors_fp(stderr); #endif return NULL; @@ -612,7 +614,7 @@ make_https_connection(BIO *bio, const URLSpec &url) const { downloader_cat.info() << "Could not establish SSL handshake with " << url.get_server() << ":" << url.get_port() << "\n"; -#ifndef NDEBUG +#ifdef REPORT_SSL_ERRORS ERR_print_errors_fp(stderr); #endif BIO_free_all(bio); @@ -868,8 +870,14 @@ send_request(BIO *bio, const string &method, << "Connection: close\r\n"; } + if (!body.empty()) { + request + << "Content-type: application/x-www-form-urlencoded\r\n" + << "Content-Length: " << body.length() << "\r\n"; + } + request - << "\r\n" + << "\r\n" << body; string request_str = request.str();