cURL / Mailing Lists / curl-library / Single Mail

curl-library

ask help for using lbcurl to access data via https and proxy at the same time

From: Cris <2233244107_at_qq.com>
Date: Thu, 27 Nov 2014 11:36:01 +0800

Hi,
  
 I am using the libcurl to post data for a https URL via internal proxy, but it can not work, what parameters/else shall I set?
  
 I ever used the same setting to access a http URL via proxy, it works; I also have tried to access a internal https URL without proxy, it also works.
  
 The settings I have made as below:
  
case Request::httpPost: {
 
const RequestPost& post = *(RequestPost*)&request;
 
CURL_FUNC(curl_easy_setopt( m_ClientEasy, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL), CLC_NOT_AVAILABLE);
 
CURL_FUNC(curl_easy_setopt( m_ClientEasy, CURLOPT_POST, 1), CLC_NOT_AVAILABLE);
 
requestHeaders.push_back(Header("Content-Type", post.contentType()));
 
requestHeaders.push_back(Header("Content-Length", String::format("%u",post.entity().size())));
 
CURL_FUNC(curl_easy_setopt(m_ClientEasy, CURLOPT_POSTFIELDS, &post.entity()[0]), CLC_NOT_AVAILABLE);
 
CURL_FUNC(curl_easy_setopt(m_ClientEasy, CURLOPT_POSTFIELDSIZE, post.entity().size()), CLC_NOT_AVAILABLE);
 
break;
 
}
 
 
 
CURL_FUNC(curl_easy_setopt(m_ClientEasy, CURLOPT_URL, &request.URL().toByteArray(false, true)[0]), CLC_NOT_AVAILABLE);
 
// build headers
 
for (size_t i=0; i<requestHeaders.size(); i++) {
 
m_CurlHeaders = curl_slist_append( (curl_slist*)m_CurlHeaders ,
 
(char*)&(requestHeaders[i].key() + ": " + requestHeaders[i].value()).toByteArray(false, true)[0] );
 
}
 
m_ResponseWeakRef = response;
 
if (response) {
 
response->clear();
 
CURL_FUNC(curl_easy_setopt(m_ClientEasy, CURLOPT_WRITEFUNCTION, &response->contentCallbackFunc), CLC_NOT_AVAILABLE);
 
CURL_FUNC(curl_easy_setopt(m_ClientEasy, CURLOPT_WRITEDATA, response), CLC_NOT_AVAILABLE);
 
CURL_FUNC(curl_easy_setopt(m_ClientEasy, CURLOPT_HEADERFUNCTION, &response->headersCallbackFunc), CLC_NOT_AVAILABLE);
 
CURL_FUNC(curl_easy_setopt(m_ClientEasy, CURLOPT_HEADERDATA, response), CLC_NOT_AVAILABLE);
 
}
 
CURL_FUNC(curl_easy_setopt(m_ClientEasy, CURLOPT_HTTPHEADER, m_CurlHeaders), CLC_NOT_AVAILABLE);
 
CURL_FUNC(curl_easy_setopt(m_ClientEasy, CURLOPT_NOBODY, request.bodyRequired() ? 0 : 1), CLC_NOT_AVAILABLE);
 
 
 
CURL_FUNC(curl_easy_setopt(m_ClientEasy, CURLOPT_SSL_VERIFYPEER, (!m_BundleCA.empty() && m_SSLCheck) ? 1 : 0), CLC_NOT_AVAILABLE);
 
CURL_FUNC(curl_easy_setopt(m_ClientEasy, CURLOPT_SSL_VERIFYHOST, (!m_BundleCA.empty() && m_SSLCheck) ? 2 : 0), CLC_NOT_AVAILABLE);
 
CURL_FUNC(curl_easy_setopt(m_ClientEasy, CURLOPT_FOLLOWLOCATION, 1), CLC_NOT_AVAILABLE);
 
CURL_FUNC(curl_easy_setopt(m_ClientEasy, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL), CLC_NOT_AVAILABLE);
 
CURL_FUNC(curl_easy_setopt(m_ClientEasy, CURLOPT_PROXY, m_ProxyAddress.toStdString().c_str()), CLC_NOT_AVAILABLE);
 
CURL_FUNC(curl_easy_setopt(m_ClientEasy, CURLOPT_HTTPPROXYTUNNEL, m_ProxyTunnel ? 1 : 0), CLC_NOT_AVAILABLE);
 
 
 

 
CLC_RETURN(CLC_SUCCESS);
 
 

  
 Any idea?
  
 Thanks a lot.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-11-27