|
@@ -665,7 +665,7 @@ const bool CHTTPClient::UploadForm(const std::string& strURL,
|
|
|
/************************************************************************/
|
|
|
/* add by cfq 添加文件块上传 */
|
|
|
/************************************************************************/
|
|
|
-const bool CHTTPClient:: UploadFileBlock(CHTTPUploadReq &req, CHTTPUploadRet &ret)
|
|
|
+const bool CHTTPClient:: UploadFileBlock(CHTTPUploadReq &req, CHTTPUploadRet &ret, HttpClientTraceLink* pTrace)
|
|
|
{
|
|
|
if(req.url.empty()){
|
|
|
if (m_eSettingsFlags & ENABLE_LOG)
|
|
@@ -696,6 +696,28 @@ const bool CHTTPClient:: UploadFileBlock(CHTTPUploadReq &req, CHTTPUploadRet &re
|
|
|
/** Now specify we want to POST data */
|
|
|
curl_easy_setopt(m_pCurlSession, CURLOPT_POST, 1L);
|
|
|
|
|
|
+ unordered_map<string, string> m_headers;
|
|
|
+ if (pTrace != NULL
|
|
|
+ && strlen(pTrace->X_B3_BusinessId) > 0
|
|
|
+ && strlen(pTrace->X_B3_TraceId) > 0
|
|
|
+ && strlen(pTrace->X_B3_SpanId) > 0
|
|
|
+ && strlen(pTrace->X_B3_ParentSpanId) > 0
|
|
|
+ && strlen(pTrace->X_B3_Timestamp) > 0)
|
|
|
+ {
|
|
|
+ m_headers.emplace(std::make_pair("X_B3_BusinessId", pTrace->X_B3_BusinessId));
|
|
|
+ m_headers.emplace(std::make_pair("X_B3_TraceId", pTrace->X_B3_TraceId));
|
|
|
+ m_headers.emplace(std::make_pair("X_B3_SpanId", pTrace->X_B3_SpanId));
|
|
|
+ m_headers.emplace(std::make_pair("X_B3_ParentSpanId", pTrace->X_B3_ParentSpanId));
|
|
|
+ m_headers.emplace(std::make_pair("X_B3_Timestamp", pTrace->X_B3_Timestamp));
|
|
|
+ }
|
|
|
+ std::string strHeader;
|
|
|
+ for (HeadersMap::const_iterator it = m_headers.cbegin();
|
|
|
+ it != m_headers.cend();
|
|
|
+ ++it)
|
|
|
+ {
|
|
|
+ strHeader = it->first + ": " + it->second; // build header string
|
|
|
+ AddHeader(strHeader);
|
|
|
+ }
|
|
|
/* stating that Expect: 100-continue is not wanted */
|
|
|
AddHeader("Expect:");
|
|
|
curl_httppost* pFormPost = NULL;
|
|
@@ -804,7 +826,7 @@ const bool CHTTPClient:: UploadFileBlock(CHTTPUploadReq &req, CHTTPUploadRet &re
|
|
|
/************************************************************************/
|
|
|
/* add by cfq 添加文件块下载 */
|
|
|
/************************************************************************/
|
|
|
-const bool CHTTPClient:: DownloadFileBlock(const char* url, const char* jsonReqStr, fileContentArray& content, long &httpCode, unordered_map<string, string>& responseHeaders, long timeout)
|
|
|
+const bool CHTTPClient:: DownloadFileBlock(const char* url, const char* jsonReqStr, fileContentArray& content, long &httpCode, unordered_map<string, string>& responseHeaders, long timeout, HttpClientTraceLink* pTrace)
|
|
|
{
|
|
|
if (url == nullptr)
|
|
|
return false;
|
|
@@ -822,6 +844,30 @@ const bool CHTTPClient:: DownloadFileBlock(const char* url, const char* jsonReqS
|
|
|
CheckURL(url);
|
|
|
|
|
|
if(content.copyPtr != NULL){
|
|
|
+ // Add headers
|
|
|
+ unordered_map<string, string> m_headers;
|
|
|
+ if (pTrace != NULL
|
|
|
+ && strlen(pTrace->X_B3_BusinessId) > 0
|
|
|
+ && strlen(pTrace->X_B3_TraceId) > 0
|
|
|
+ && strlen(pTrace->X_B3_SpanId) > 0
|
|
|
+ && strlen(pTrace->X_B3_ParentSpanId) > 0
|
|
|
+ && strlen(pTrace->X_B3_Timestamp) > 0)
|
|
|
+ {
|
|
|
+ m_headers.emplace(std::make_pair("X_B3_BusinessId", pTrace->X_B3_BusinessId));
|
|
|
+ m_headers.emplace(std::make_pair("X_B3_TraceId", pTrace->X_B3_TraceId));
|
|
|
+ m_headers.emplace(std::make_pair("X_B3_SpanId", pTrace->X_B3_SpanId));
|
|
|
+ m_headers.emplace(std::make_pair("X_B3_ParentSpanId", pTrace->X_B3_ParentSpanId));
|
|
|
+ m_headers.emplace(std::make_pair("X_B3_Timestamp", pTrace->X_B3_Timestamp));
|
|
|
+ }
|
|
|
+ std::string strHeader;
|
|
|
+ for (HeadersMap::const_iterator it = m_headers.cbegin();
|
|
|
+ it != m_headers.cend();
|
|
|
+ ++it)
|
|
|
+ {
|
|
|
+ strHeader = it->first + ": " + it->second; // build header string
|
|
|
+ AddHeader(strHeader);
|
|
|
+ }
|
|
|
+
|
|
|
curl_easy_setopt(m_pCurlSession, CURLOPT_HTTPPOST, 1);
|
|
|
curl_easy_setopt(m_pCurlSession, CURLOPT_POSTFIELDS, jsonReqStr);
|
|
|
//接受响应头
|