Skip to content

Commit 37deb65

Browse files
committed
change httpclient state to page
1 parent d7df273 commit 37deb65

4 files changed

Lines changed: 272 additions & 272 deletions

File tree

controller/src/test_weixin.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,13 @@ std::string test_xcxgetphone(std::shared_ptr<httppeer> peer)
173173
/*
174174
缓存 access_token
175175
176-
td::string cache_data = a->state.json["access_token"].to_string();
176+
td::string cache_data = a->page.json["access_token"].to_string();
177177
temp_cache.save(access_token, cache_data, 30);
178178
179179
*/
180180

181181
response = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=";
182-
response.append(a->state.json["access_token"].to_string());
182+
response.append(a->page.json["access_token"].to_string());
183183
http::obj_val postitem;
184184
postitem["code"] = code;
185185
//std::shared_ptr<http::client> b = std::make_shared<http::client>();
@@ -195,7 +195,7 @@ std::string test_xcxgetphone(std::shared_ptr<httppeer> peer)
195195
return "";
196196
}
197197
response.clear();
198-
response = a->state.json["phone_info"]["phoneNumber"].to_string();
198+
response = a->page.json["phone_info"]["phoneNumber"].to_string();
199199

200200
if (response.size() < 6)
201201
{

controller/src/testcowaitclient.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ std::string testhttpclient_downfilelist(std::shared_ptr<httppeer> peer)
277277
tempurl.append(std::to_string(i));
278278
tempurl.append(urls[1]);
279279
a->requst_clear();
280-
a->state.json.clear();
280+
a->page.json.clear();
281281
std::cout<<tempurl<<std::endl;
282282
a->get_json(tempurl);
283283
a->add_header("Connection", "keep-alive");
@@ -289,18 +289,18 @@ std::string testhttpclient_downfilelist(std::shared_ptr<httppeer> peer)
289289
if (a->get_status() == 200)
290290
{
291291
std::cout<<"resp ok"<<std::endl;
292-
if(a->state.isjson ==1)
292+
if(a->page.isjson ==1)
293293
{
294294
std::cout<<"begin json"<<std::endl;
295-
if(a->state.json["code"].to_int()==0)
295+
if(a->page.json["code"].to_int()==0)
296296
{
297-
if(a->state.json["data"].is_array())
297+
if(a->page.json["data"].is_array())
298298
{
299299
std::cout<<"is_array"<<std::endl;
300300
unsigned int j=0;
301-
for(;j<a->state.json["data"].size();j++)
301+
for(;j<a->page.json["data"].size();j++)
302302
{
303-
std::cout<<"fid:" <<a->state.json["data"][j]["aritcleid"].to_string()<<std::endl;
303+
std::cout<<"fid:" <<a->page.json["data"][j]["aritcleid"].to_string()<<std::endl;
304304
}
305305

306306
if(j>0)
@@ -310,12 +310,12 @@ std::string testhttpclient_downfilelist(std::shared_ptr<httppeer> peer)
310310
}
311311

312312
}
313-
else if(a->state.json["data"].is_obj())
313+
else if(a->page.json["data"].is_obj())
314314
{
315315

316316
std::cout<<"is_obj"<<std::endl;
317317
}
318-
std::cout << a->state.content << std::endl;
318+
std::cout << a->page.content << std::endl;
319319
continue;
320320
}
321321
std::cout<<"json error!"<<std::endl;
@@ -381,12 +381,12 @@ std::string testhttpclient_getdownfile(std::shared_ptr<httppeer> peer)
381381
if (a->get_status() == 200)
382382
{
383383
std::cout<<"----get ok----\n"<<std::endl;
384-
if(a->state.istxt==false)
384+
if(a->page.istxt==false)
385385
{
386-
if(a->state.page.tempfile.size()>0)
386+
if(a->page.file.tempfile.size()>0)
387387
{
388-
std::cout<<"filename:"<<a->state.page.filename<<std::endl;
389-
fileurl = a->state.page.filename;
388+
std::cout<<"filename:"<<a->page.file.filename<<std::endl;
389+
fileurl = a->page.file.filename;
390390

391391
client << "<html><head>";
392392
client <<"<meta http-equiv=\"refresh\" content=\"1;url=/downfilecontent\">";

vendor/httpserver/include/httpclient.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ class client : public std::enable_shared_from_this<client>
111111
void set_limit_time(unsigned short t) { timeout_total = t; };
112112
void clear_limit_time_count() { timeout_count = 0; };
113113

114-
bool is_file() { return !state.istxt; };
115-
bool is_json() { return state.isjson; };
114+
bool is_file() { return !page.istxt; };
115+
bool is_json() { return page.isjson; };
116116
bool init_http_sock();
117117
bool init_https_sock();
118118

@@ -166,7 +166,7 @@ class client : public std::enable_shared_from_this<client>
166166
unsigned char requesttype = 0;
167167
bool isssl = false;
168168
std::atomic_bool iswait_exit = false;
169-
struct state_t
169+
struct page_t
170170
{
171171
long long length = 0;
172172
unsigned int code = 0;
@@ -180,9 +180,9 @@ class client : public std::enable_shared_from_this<client>
180180
std::string codemessage;
181181
std::map<std::string, std::string> header;
182182
http::cookie cookie;
183-
upload_file page;
183+
upload_file file;
184184
http::obj_val json;
185-
} state;
185+
} page;
186186

187187
std::shared_ptr<asio::ip::tcp::socket> sock = {nullptr};
188188
std::shared_ptr<asio::ssl::stream<asio::ip::tcp::socket>> sslsock = {nullptr};

0 commit comments

Comments
 (0)