22#include < windows.h>
33#include < tchar.h>
44#pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib")
5+ #pragma comment(lib,"XEngine_Core/XEngine_OPenSsl")
56#pragma comment(lib,"XEngine_NetHelp/NetHelp_APIClient")
67#pragma comment(lib,"Ws2_32")
78#ifdef _WIN64
2021#include < XEngine_Include/XEngine_ProtocolHdr.h>
2122#include < XEngine_Include/XEngine_BaseLib/BaseLib_Define.h>
2223#include < XEngine_Include/XEngine_BaseLib/BaseLib_Error.h>
24+ #include < XEngine_Include/XEngine_Core/OPenSsl_Define.h>
25+ #include < XEngine_Include/XEngine_Core/OPenSsl_Error.h>
2326#include < XEngine_Include/XEngine_NetHelp/APIClient_Define.h>
2427#include < XEngine_Include/XEngine_NetHelp/APIClient_Error.h>
2528using namespace std ;
2629
27- // g++ -std=c++17 -Wall -g APPClient_RestApi.cpp -o APPClient_RestApi.exe -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_BaseLib -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_NetHelp -lXEngine_BaseLib -lNetHelp_APIClient -ljsoncpp -Wl,-rpath=../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_BaseLib:../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_NetHelp,--disable-new-dtags
30+ // g++ -std=c++17 -Wall -g APPClient_RestApi.cpp -o APPClient_RestApi.exe -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_Core -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_NetHelp -lXEngine_BaseLib -lNetHelp_APIClient -ljsoncpp -Wl,-rpath=../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_BaseLib:../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_NetHelp,--disable-new-dtags
2831// 需要优先配置XEngine
2932// WINDOWS使用VS2022 x86 或者 x64 debug 编译
3033// linux使用下面的命令编译
31- // g++ -std=c++17 -Wall -g APPClient_RestApi.cpp -o APPClient_RestApi.exe -I ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_NetHelp -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lNetHelp_APIClient -ljsoncpp
34+ // g++ -std=c++17 -Wall -g APPClient_RestApi.cpp -o APPClient_RestApi.exe -I ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_Core -L /usr/local/lib/XEngine_Release/ XEngine_NetHelp -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lNetHelp_APIClient -ljsoncpp
3235
36+ XCHAR tszBaseBuffer[MAX_PATH];
37+ XCHAR tszHdrBuffer[MAX_PATH];
3338// 查询
3439void API_Manage_Query ()
3540{
36- LPCXSTR lpszUrl = _X (" http://192.168.1.8 :5100/Api/Manage/QueryFile" );
41+ LPCXSTR lpszUrl = _X (" http://127.0.0.1 :5100/Api/Manage/QueryFile" );
3742 int nLen = 0 ;
3843 int nCode = 0 ;
3944 XCHAR* ptszMsgBuffer = NULL ;
4045 Json::Value st_JsonRoot;
46+
4147 st_JsonRoot[" lpszTimeStart" ];
4248 st_JsonRoot[" lpszTimeEnd" ];
4349 st_JsonRoot[" lpszBuckKey" ] = " storagekey2" ;
4450
45- if (!APIClient_Http_Request (_X (" POST" ), lpszUrl, st_JsonRoot.toStyledString ().c_str (), &nCode, &ptszMsgBuffer, &nLen))
51+ if (!APIClient_Http_Request (_X (" POST" ), lpszUrl, st_JsonRoot.toStyledString ().c_str (), &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer ))
4652 {
4753 _xtprintf (" API_Manage_Query:%lX\n " , APIClient_GetLastError ());
4854 return ;
@@ -53,7 +59,7 @@ void API_Manage_Query()
5359// 插入
5460void API_Manage_Insert ()
5561{
56- LPCXSTR lpszUrl = _X (" http://192.168.1.8 :5100/Api/Manage/Insert" );
62+ LPCXSTR lpszUrl = _X (" http://127.0.0.1 :5100/Api/Manage/Insert" );
5763 int nLen = 0 ;
5864 int nCode = 0 ;
5965 XCHAR* ptszMsgBuffer = NULL ;
@@ -70,7 +76,7 @@ void API_Manage_Insert()
7076 st_JsonRoot[" List" ] = st_JsonArray;
7177 st_JsonRoot[" Count" ] = 1 ;
7278
73- if (!APIClient_Http_Request (_X (" POST" ), lpszUrl, st_JsonRoot.toStyledString ().c_str (), &nCode, &ptszMsgBuffer, &nLen))
79+ if (!APIClient_Http_Request (_X (" POST" ), lpszUrl, st_JsonRoot.toStyledString ().c_str (), &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer ))
7480 {
7581 _xtprintf (" API_Manage_Insert:%lX\n " , APIClient_GetLastError ());
7682 return ;
@@ -81,7 +87,7 @@ void API_Manage_Insert()
8187// 删除
8288void API_Manage_Delete ()
8389{
84- LPCXSTR lpszUrl = _X (" http://192.168.1.8 :5100/Api/Manage/Delete" );
90+ LPCXSTR lpszUrl = _X (" http://127.0.0.1 :5100/Api/Manage/Delete" );
8591 int nLen = 0 ;
8692 int nCode = 0 ;
8793 XCHAR* ptszMsgBuffer = NULL ;
@@ -95,7 +101,7 @@ void API_Manage_Delete()
95101 st_JsonRoot[" List" ] = st_JsonArray;
96102 st_JsonRoot[" Count" ] = 1 ;
97103
98- if (!APIClient_Http_Request (_X (" POST" ), lpszUrl, st_JsonRoot.toStyledString ().c_str (), &nCode, &ptszMsgBuffer, &nLen))
104+ if (!APIClient_Http_Request (_X (" POST" ), lpszUrl, st_JsonRoot.toStyledString ().c_str (), &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer ))
99105 {
100106 _xtprintf (" API_Manage_Delete:%lX\n " , APIClient_GetLastError ());
101107 return ;
@@ -106,7 +112,7 @@ void API_Manage_Delete()
106112// 文件夹
107113void API_Manage_Dir ()
108114{
109- LPCXSTR lpszUrl = _X (" http://192.168.1.8 :5100/Api/Manage/Dir" );
115+ LPCXSTR lpszUrl = _X (" http://127.0.0.1 :5100/Api/Manage/Dir" );
110116 int nLen = 0 ;
111117 int nCode = 0 ;
112118 XCHAR* ptszMsgBuffer = NULL ;
@@ -115,7 +121,7 @@ void API_Manage_Dir()
115121 st_JsonRoot[" lpszBuckKey" ] = " storagekey1" ;
116122 st_JsonRoot[" lpszUserDir" ] = " user" ;
117123 st_JsonRoot[" nOPerator" ] = 1 ;
118- if (!APIClient_Http_Request (_X (" POST" ), lpszUrl, st_JsonRoot.toStyledString ().c_str (), &nCode, &ptszMsgBuffer, &nLen))
124+ if (!APIClient_Http_Request (_X (" POST" ), lpszUrl, st_JsonRoot.toStyledString ().c_str (), &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer ))
119125 {
120126 _xtprintf (" API_Manage_Dir:%lX\n " , APIClient_GetLastError ());
121127 return ;
@@ -127,7 +133,7 @@ void API_Manage_Dir()
127133 st_JsonRoot[" lpszBuckKey" ] = " storagekey1" ;
128134 st_JsonRoot[" lpszUserDir" ];
129135 st_JsonRoot[" nOPerator" ] = 0 ;
130- if (!APIClient_Http_Request (_X (" POST" ), lpszUrl, st_JsonRoot.toStyledString ().c_str (), &nCode, &ptszMsgBuffer, &nLen))
136+ if (!APIClient_Http_Request (_X (" POST" ), lpszUrl, st_JsonRoot.toStyledString ().c_str (), &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer ))
131137 {
132138 _xtprintf (" API_Manage_Dir:%lX\n " , APIClient_GetLastError ());
133139 return ;
@@ -139,7 +145,7 @@ void API_Manage_Dir()
139145 st_JsonRoot[" lpszBuckKey" ] = " storagekey1" ;
140146 st_JsonRoot[" lpszUserDir" ] = " user" ;
141147 st_JsonRoot[" nOPerator" ] = 2 ;
142- if (!APIClient_Http_Request (_X (" POST" ), lpszUrl, st_JsonRoot.toStyledString ().c_str (), &nCode, &ptszMsgBuffer, &nLen))
148+ if (!APIClient_Http_Request (_X (" POST" ), lpszUrl, st_JsonRoot.toStyledString ().c_str (), &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer ))
143149 {
144150 _xtprintf (" API_Manage_Dir:%lX\n " , APIClient_GetLastError ());
145151 return ;
@@ -150,11 +156,11 @@ void API_Manage_Dir()
150156// 任务管理
151157void API_Manage_Task ()
152158{
153- LPCXSTR lpszUrl = _X (" http://192.168.1.8 :5100/Api/Manage/Task" );
159+ LPCXSTR lpszUrl = _X (" http://127.0.0.1 :5100/Api/Manage/Task" );
154160 int nLen = 0 ;
155161 int nCode = 0 ;
156162 XCHAR* ptszMsgBuffer = NULL ;
157- if (!APIClient_Http_Request (_X (" POST" ), lpszUrl, NULL , &nCode, &ptszMsgBuffer, &nLen))
163+ if (!APIClient_Http_Request (_X (" POST" ), lpszUrl, NULL , &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer ))
158164 {
159165 _xtprintf (" API_Manage_Task:%lX\n " , APIClient_GetLastError ());
160166 return ;
@@ -169,6 +175,10 @@ int main()
169175 WSADATA st_WSAData;
170176 WSAStartup (MAKEWORD (2 , 2 ), &st_WSAData);
171177#endif
178+ memset (tszBaseBuffer, ' \0 ' , MAX_PATH);
179+ memset (tszHdrBuffer, ' \0 ' , MAX_PATH);
180+ OPenSsl_Help_BasicEncoder (" 123123aa" , " 123123" , tszBaseBuffer);
181+ _xstprintf (tszHdrBuffer, _X (" Authorization: %s\r\n " ), tszBaseBuffer);
172182
173183 API_Manage_Query ();
174184 API_Manage_Insert ();
0 commit comments