in client.cpp [414:467]
PostLogStoreLogsResponse LOGClient::PostLogStoreLogs(const string& project, const string& logstore, const pb::LogGroup& logGroup,const std::string& hashKey)
{
string body;
string serializeData;
if (logGroup.source.empty())
{
pb::LogGroup newLogGroup;
newLogGroup = logGroup;
newLogGroup.source = mSource;
newLogGroup.SerializeToString(serializeData);
}
else
{
logGroup.SerializeToString(serializeData);
}
string operation = LOGSTORES;
operation.append("/").append(logstore);
if(hashKey.empty() )
operation.append("");
else
operation.append("/shards/route");
map<string, string> httpHeader;
httpHeader[CONTENT_TYPE] = TYPE_LOG_PROTOBUF;
if(mCompressFlag)
{
if(! aliyun_log_sdk_v6::CompressAlgorithm::CompressLz4(serializeData, body))
{
throw LOGException(LOGE_UNKNOWN_ERROR, "Data compress failed.");
}
httpHeader[X_LOG_COMPRESSTYPE] = LOG_LZ4;
}
else
{
body = serializeData;
}
httpHeader[X_LOG_BODYRAWSIZE] = std::to_string(serializeData.size());
httpHeader[CONTENT_MD5] = CodecTool::CalcMD5(body);
map<string, string> parameterList;
if(hashKey.empty() == false)
parameterList["key"] = hashKey;
SetCommonParameter(parameterList);
HttpMessage httpResponse;
SendRequest(project, HTTP_POST, operation, body, parameterList, httpHeader, httpResponse);
PostLogStoreLogsResponse ret;
ret.bodyBytes = body.size();
ret.statusCode = httpResponse.statusCode;
ret.requestId = httpResponse.header[X_LOG_REQUEST_ID];
return ret;
}