From aee9f6abc80ccd83630c0f9dad102127b43d294b Mon Sep 17 00:00:00 2001 From: cora32 Date: Sun, 19 Apr 2015 02:24:44 +0300 Subject: [PATCH] HttpDigest fix. --- Connector.cpp | 27 ++++++++++++++++++++------- version | 2 +- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Connector.cpp b/Connector.cpp index ee86ed9..158815e 100644 --- a/Connector.cpp +++ b/Connector.cpp @@ -171,14 +171,27 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer, curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk); } - if (lpString != NULL) { - if(digestMode) curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST); - curl_easy_setopt(curl, CURLOPT_UNRESTRICTED_AUTH, 1L); - curl_easy_setopt(curl, CURLOPT_FTPLISTONLY, 1L); + int res = 0; + + if (lpString != NULL) { + curl_easy_setopt(curl, CURLOPT_UNRESTRICTED_AUTH, 1L); + curl_easy_setopt(curl, CURLOPT_FTPLISTONLY, 1L); curl_easy_setopt(curl, CURLOPT_USERPWD, lpString->c_str()); - }; - - int res = curl_easy_perform(curl); + if (digestMode) + { + curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST); + res = curl_easy_perform(curl); + + if (port != 21 && lpString != NULL) { + int pos = Utils::ustrstr(*buffer, "\r\n\r\n"); + if (pos != -1) { + *buffer = buffer->substr(pos + 4); + } + } + } + else res = curl_easy_perform(curl); + } + else res = curl_easy_perform(curl); curl_easy_cleanup(curl); if (res == CURLE_OK || diff --git a/version b/version index f02d37e..788ef1f 100644 --- a/version +++ b/version @@ -1 +1 @@ -24B93-9B \ No newline at end of file +24B93-D0 \ No newline at end of file