|
@@ -825,6 +825,26 @@ void CWSCodec::SerializeGetVarReq(cJSON* js, char* data, int* wpos, int* capacit
|
|
|
void CWSCodec::GeneralSerialize(cJSON* js, char* data, int* wpos, int* capacity, CMedthodInterface* pI, char* errmsg){
|
|
|
std::list<CMethodParam>::iterator it = pI->mRequestInterpreter.mParamList.begin();
|
|
|
|
|
|
+ auto dealBlob = [](CSimpleString src, char* bin)->std::pair <int, std::string> {
|
|
|
+ if (!is_base64(src))
|
|
|
+ return std::make_pair(-1, "base64 decode failed!");
|
|
|
+
|
|
|
+ int binlen = modp_b64_decode_len(src.GetLength()) - 1;//二进制流,不需要结束
|
|
|
+
|
|
|
+ if (binlen > 0)
|
|
|
+ {
|
|
|
+ bin = new char[binlen + 1];
|
|
|
+ ZeroMemory(bin, binlen + 1);
|
|
|
+ modp_b64_decode(bin, src.GetData(), src.GetLength());//binlen有可能比bin长
|
|
|
+ short objectNum = *((short*)bin);
|
|
|
+ int extendLen = 2 + objectNum * 2;
|
|
|
+ int dstLen = binlen - (binlen - extendLen) % 4;
|
|
|
+ return std::make_pair(dstLen, "");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ return std::make_pair(-1, "error binlen");
|
|
|
+ };
|
|
|
+
|
|
|
while(it != pI->mRequestInterpreter.mParamList.end()){
|
|
|
if (it->mType == "int")
|
|
|
{
|
|
@@ -950,28 +970,11 @@ void CWSCodec::GeneralSerialize(cJSON* js, char* data, int* wpos, int* capacity,
|
|
|
}
|
|
|
else if (it->mType == "blob")
|
|
|
{
|
|
|
- CSimpleStringA d = "";
|
|
|
- GetCJsonObjectValue(js, it->mName.c_str(), d, errmsg);
|
|
|
-
|
|
|
- auto dealBlob = [](CSimpleString src, char* bin)->std::pair <int, std::string> {
|
|
|
- if (!is_base64(src))
|
|
|
- return std::make_pair(-1, "base64 decode failed!");
|
|
|
+ CSimpleStringA d = "";
|
|
|
+ GetCJsonObjectValue(js, it->mName.c_str(), d, errmsg);
|
|
|
+ /*
|
|
|
|
|
|
- int binlen = modp_b64_decode_len(src.GetLength()) - 1;//二进制流,不需要结束
|
|
|
-
|
|
|
- if (binlen > 0)
|
|
|
- {
|
|
|
- bin = new char[binlen + 1];
|
|
|
- ZeroMemory(bin, binlen + 1);
|
|
|
- modp_b64_decode(bin, src.GetData(), src.GetLength());//binlen有可能比bin长
|
|
|
- short objectNum = *((short*)bin);
|
|
|
- int extendLen = 2 + objectNum * 2;
|
|
|
- int dstLen = binlen - (binlen - extendLen) % 4;
|
|
|
- return std::make_pair(dstLen, "");
|
|
|
- }
|
|
|
- else
|
|
|
- return std::make_pair(-1, "error binlen");
|
|
|
- };
|
|
|
+
|
|
|
|
|
|
char* bin = NULL;
|
|
|
auto dealret = dealBlob(d, bin);
|
|
@@ -982,8 +985,8 @@ void CWSCodec::GeneralSerialize(cJSON* js, char* data, int* wpos, int* capacity,
|
|
|
}
|
|
|
else
|
|
|
DbgEx("Blob:dealBlob error:%d, %s", dealret.first, dealret.second.c_str());
|
|
|
-
|
|
|
- /*
|
|
|
+ */
|
|
|
+
|
|
|
if(!is_base64(d)){
|
|
|
strcat(errmsg, "base64 decode failed!");
|
|
|
++it;
|
|
@@ -1013,8 +1016,8 @@ void CWSCodec::GeneralSerialize(cJSON* js, char* data, int* wpos, int* capacity,
|
|
|
|
|
|
delete[]bin;
|
|
|
bin = NULL;
|
|
|
- }
|
|
|
- */
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
else if (it->mType == "array_blob") {
|
|
|
int len = 0;
|