|
@@ -43,67 +43,44 @@ void test_get()
|
|
|
system("pause");
|
|
|
}
|
|
|
|
|
|
-void test_post()
|
|
|
+void test_getmessageV2()
|
|
|
{
|
|
|
- HTTPRESULT result;
|
|
|
+ HTTPRESULT res;
|
|
|
HTTPHelper hhelper;
|
|
|
hhelper.SetMethod(L"POST");
|
|
|
- //hhelper.AddRequestHeaders(L"Cache-Control", L"no-cache");
|
|
|
- hhelper.AddRequestHeaders(L"User-Agent", L"Moka_Factory/1.0.01");
|
|
|
- //hhelper.AddRequestHeaders(L"Accept", L"*/*");
|
|
|
#pragma region 造成Post时返回分块编码的原因是:Accept-Encoding中gzip造成数据压缩传输了.
|
|
|
- //hhelper.AddRequestHeaders(L"Accept-Encoding", L"gzip, deflate, br");
|
|
|
- //hhelper.AddRequestHeaders(L"Connection", L"keep-alive");//持续连接,会产生分块编码(Transfer-Encoding: chunked)
|
|
|
- hhelper.AddRequestHeaders(L"Connection", L"close"); //关闭,也一样会产生会分块编码(Transfer-Encoding: chunked)
|
|
|
- //hhelper.AddRequestHeaders(L"Transfer-Encoding", L""); //关闭,也一样会产生会分块编码(Transfer-Encoding: chunked)
|
|
|
+ // 禁用此头后,接口数据返回正常;
|
|
|
+ // hhelper.AddRequestHeaders(L"Accept-Encoding", L"gzip, deflate, br");
|
|
|
#pragma endregion
|
|
|
- //content-encoding
|
|
|
- //hhelper.AddRequestHeaders(L"Content-Encoding", L"UTF-8"); // POST时才需要用到;
|
|
|
- hhelper.AddRequestHeaders(L"Content-Type", L"application/json;charset=utf8"); // POST时才需要用到;
|
|
|
- //hhelper.AddRequestHeaders(L"Content-Length", L"755"); // POST时才需要用到
|
|
|
hhelper.SetUrl(L"http://test.scbc.qhmoka.com/scbc-server/clientType/getMessage.do");
|
|
|
- //hhelper.SetPostData(L"{\"bid\":\"TEST_WJF\",\"mac\":\"04-D4-C4-EE-6B-CD\"}");
|
|
|
- hhelper.AddBodyRawData("{\"bid\":\"TEST_WJF\",\"mac\":\"04-D4-C4-EE-6B-CD\"}", L"application/json");
|
|
|
- hhelper.GetHtml(result);
|
|
|
+ hhelper.AddBodyRawData("{\"bid\":\"TEST_WJF\",\"mac\":\"04-D4-C4-EE-6B-CD\"}", L"application/json;charset=utf-8");
|
|
|
+ hhelper.GetHtml(res);
|
|
|
|
|
|
- wprintf(L"ResponseHeader=%s\r\n",result.m_strHeader.c_str());
|
|
|
- wprintf(L"StatusCode=%ld\r\n", result.m_dwStatusCode);
|
|
|
+ wprintf(L"ResponseHeader=%s\r\n",res.m_strHeader.c_str());
|
|
|
+ wprintf(L"StatusCode=%ld\r\n", res.m_dwStatusCode);
|
|
|
|
|
|
- if (result.m_dwStatusCode == 200)
|
|
|
- printf("ResponseData=%s\r\n",result.m_strResponseData.c_str());
|
|
|
+ if (res.m_dwStatusCode == 200)
|
|
|
+ printf("ResponseData=%s\r\n",res.m_strResponseData.c_str());
|
|
|
|
|
|
system("pause");
|
|
|
|
|
|
int a = 0;
|
|
|
}
|
|
|
|
|
|
-void test_post1()
|
|
|
+void test_getkey()
|
|
|
{
|
|
|
- HTTPRESULT result;
|
|
|
- HTTPHelper hhelper;
|
|
|
- hhelper.SetMethod(L"POST");
|
|
|
- hhelper.AddRequestHeaders(L"Cache-Control", L"no-cache");
|
|
|
- hhelper.AddRequestHeaders(L"User-Agent", L"Moka_Factory/1.0.01");
|
|
|
- hhelper.AddRequestHeaders(L"Accept", L"*/*");
|
|
|
-#pragma region 造成Post时返回分块编码的原因是:Accept-Encoding中gzip造成数据压缩传输了.
|
|
|
- hhelper.AddRequestHeaders(L"Accept-Encoding", L"gzip, deflate, br");
|
|
|
- hhelper.AddRequestHeaders(L"Connection", L"keep-alive");
|
|
|
- //hhelper.AddRequestHeaders(L"Connection", L"close"); //关闭,也一样会产生会分块编码(Transfer-Encoding: chunked)
|
|
|
- //hhelper.AddRequestHeaders(L"Transfer-Encoding", L""); //关闭,也一样会产生会分块编码(Transfer-Encoding: chunked)
|
|
|
-#pragma endregion
|
|
|
- //content-encoding
|
|
|
- //hhelper.AddRequestHeaders(L"Content-Encoding", L"UTF-8"); // POST时才需要用到;
|
|
|
- //hhelper.AddRequestHeaders(L"Content-Type", L"application/json;charset=utf8"); // POST时才需要用到;
|
|
|
- //hhelper.AddRequestHeaders(L"Content-Length", L"755"); // POST时才需要用到
|
|
|
- hhelper.SetUrl(L"http://test.idmanage.qhmoka.com/IDManage/v2/bind/order");
|
|
|
- hhelper.AddBodyRawData("{\"orderNum\":\"TEST_WJF\",\"sn\":\"SN0321-test9999\",\"psn\":\"20220321APSN9999\",\"orderCode\":\"BBB\",\"skipKey\": []}", L"application/json;charset=utf8");
|
|
|
- hhelper.GetHtml(result);
|
|
|
+ HTTPRESULT res;
|
|
|
+ HTTPHelper http;
|
|
|
+ http.SetMethod(L"POST");
|
|
|
+ http.SetUrl(L"http://test.idmanage.qhmoka.com/IDManage/v2/bind/order");
|
|
|
+ http.AddBodyRawData("{\"orderNum\":\"TEST_WJF\",\"sn\":\"SN0321-test9999\",\"psn\":\"20220321APSN9999\",\"orderCode\":\"BBB\",\"skipKey\": []}", L"application/json;charset=utf8");
|
|
|
+ http.GetHtml(res);
|
|
|
|
|
|
- wprintf(L"ResponseHeader=%s\r\n",result.m_strHeader.c_str());
|
|
|
- wprintf(L"StatusCode=%ld\r\n", result.m_dwStatusCode);
|
|
|
+ wprintf(L"ResponseHeader=%s\r\n",res.m_strHeader.c_str());
|
|
|
+ wprintf(L"StatusCode=%ld\r\n", res.m_dwStatusCode);
|
|
|
|
|
|
- if (result.m_dwStatusCode == 200)
|
|
|
- printf("ResponseData=%s\r\n",result.m_strResponseData.c_str());
|
|
|
+ if (res.m_dwStatusCode == 200)
|
|
|
+ printf("ResponseData=%s\r\n",res.m_strResponseData.c_str());
|
|
|
|
|
|
system("pause");
|
|
|
|
|
@@ -148,8 +125,7 @@ void test_login()
|
|
|
HTTPRESULT res;
|
|
|
HTTPHelper http;
|
|
|
http.SetMethod(L"POST");
|
|
|
- //http.SetUrl(L"http://test.scbc.qhmoka.com/scbc-server/login.do");
|
|
|
- http.SetUrl(L"https://cn.uc.qhmoka.com/scbc-server/login.do");
|
|
|
+ http.SetUrl(L"http://test.scbc.qhmoka.com/scbc-server/login.do");
|
|
|
http.AddBodyRawData("{\"account\":\"SanHua\",\"password\":\"admin\",\"mac\":\"A0-00-00-00-00-0A\"}", L"application/json;charset=utf-8");
|
|
|
|
|
|
http.GetHtml(res);
|
|
@@ -168,14 +144,28 @@ void test_updateCheck()
|
|
|
HTTPRESULT res;
|
|
|
HTTPHelper http;
|
|
|
http.SetMethod(L"POST");
|
|
|
- //http.AddRequestHeaders(L"Accept", L"application/json");
|
|
|
- //http.AddRequestHeaders(L"User-Agent", L"Moka_Factory/1.0.01");
|
|
|
- http.AddRequestHeaders(L"Content-Type", L"application/json");
|
|
|
//http.SetUrl(L"https://test.uc.qhmoka.com/ota-services/upmp/upgradeIncrForTool");
|
|
|
http.SetUrl(L"https://cn.ota.qhmoka.com/ota-services/upmp/upgradeIncrForTool");
|
|
|
- //http.SetUrl(L"https://cn.uc.qhmoka.com/scbc-server/clientType/getMessage.do");
|
|
|
http.AddBodyRawData("{\"appid\":\"SCBC_Factory_Tools\",\"devicemodel\":\"SCBC_Factory_Tools\",\"dnum\":\"111\",\"ver\":\"3.0.6.4\",\"type\":\"pc\"}", L"application/json;charset=utf-8");
|
|
|
- //http.AddBodyRawData(L"{\"clientType\":\"\",\"version\":\"\",\"bid\":\"IDE963353D\",\"mac\":\"94-DE-80-AA-CE-C9\"}", L"application/json;charset=utf-8");
|
|
|
+
|
|
|
+ http.GetHtml(res);
|
|
|
+
|
|
|
+ wprintf(L"ResponseHeader=%s\r\n",res.m_strHeader.c_str());
|
|
|
+ wprintf(L"StatusCode=%ld\r\n", res.m_dwStatusCode);
|
|
|
+
|
|
|
+ if (res.m_dwStatusCode == 200)
|
|
|
+ printf("ResponseData=%s\r\n",res.m_strResponseData.c_str());
|
|
|
+
|
|
|
+ system("pause");
|
|
|
+}
|
|
|
+
|
|
|
+void test_getmssage()
|
|
|
+{
|
|
|
+ HTTPRESULT res;
|
|
|
+ HTTPHelper http;
|
|
|
+ http.SetMethod(L"POST");
|
|
|
+ http.SetUrl(L"https://cn.uc.qhmoka.com/scbc-server/clientType/getMessage.do");
|
|
|
+ http.AddBodyRawData("{\"clientType\":\"\",\"version\":\"\",\"bid\":\"IDE963353D\",\"mac\":\"94-DE-80-AA-CE-C9\"}", L"application/json;charset=utf-8");
|
|
|
|
|
|
http.GetHtml(res);
|
|
|
|
|
@@ -193,6 +183,9 @@ void test()
|
|
|
{
|
|
|
test_login();
|
|
|
test_updateCheck();
|
|
|
+ test_getmssage();
|
|
|
+ test_getmessageV2();
|
|
|
+ test_getkey();
|
|
|
}
|
|
|
|
|
|
int _tmain(int argc, _TCHAR* argv[])
|