@@ -240,18 +240,20 @@ bool HTTP::request(const char* method, const char* endUrl, const char* data, Jso
240
240
}
241
241
242
242
// Get Json Object on web server.
243
- void HTTP::request (const char * method, const char * endUrl, const char * data, Json::Object* jOutput, Result& result, const char * content_type){
243
+ unsigned int HTTP::request (const char * method, const char * endUrl, const char * data, Json::Object* jOutput, Result& result, const char * content_type){
244
+
245
+ unsigned int statusCode = 0 ;
244
246
245
247
std::string output;
246
- request (method, endUrl, data, output, result, content_type);
248
+ statusCode = request (method, endUrl, data, output, result, content_type);
247
249
if (result != OK) {
248
250
249
251
// Give a second chance.
250
252
disconnect ();
251
253
252
- request (method, endUrl, data, output, result, content_type);
254
+ statusCode = request (method, endUrl, data, output, result, content_type);
253
255
if (result != OK)
254
- return ;
256
+ return statusCode ;
255
257
}
256
258
257
259
try {
@@ -262,7 +264,7 @@ void HTTP::request(const char* method, const char* endUrl, const char* data, Jso
262
264
catch (Exception& e){
263
265
printf (" parser() failed in Getter. Exception caught: %s\n " , e.what ());
264
266
result = ERROR;
265
- return ;
267
+ return statusCode ;
266
268
}
267
269
catch (std::exception& e){
268
270
printf (" parser() failed in Getter. std::exception caught: %s\n " , e.what ());
@@ -274,6 +276,7 @@ void HTTP::request(const char* method, const char* endUrl, const char* data, Jso
274
276
}
275
277
276
278
result = OK;
279
+ return statusCode;
277
280
}
278
281
279
282
// Parse the message and split if necessary.
@@ -420,7 +423,7 @@ bool HTTP::request(const char* method, const char* endUrl, const char* data, std
420
423
return (result == OK);
421
424
}
422
425
423
- void HTTP::request (const char * method, const char * endUrl, const char * data, std::string& output, Result& result, const char * content_type){
426
+ unsigned int HTTP::request (const char * method, const char * endUrl, const char * data, std::string& output, Result& result, const char * content_type){
424
427
425
428
// / Example of request.
426
429
// / "POST /test.php HTTP/1.0\r\n"
@@ -443,12 +446,14 @@ void HTTP::request(const char* method, const char* endUrl, const char* data, std
443
446
assert ( !error () );
444
447
assert (output.empty ());
445
448
449
+ unsigned int statusCode = 0 ;
450
+
446
451
if (!sendMessage (method, endUrl, data, content_type)) {
447
452
result = ERROR;
448
- return ;
453
+ return statusCode ;
449
454
}
450
455
451
- readMessage (output, result);
456
+ statusCode = readMessage (output, result);
452
457
if (result != OK) {
453
458
454
459
// Clear ouput in case we didn't get the full response.
@@ -472,6 +477,7 @@ void HTTP::request(const char* method, const char* endUrl, const char* data, std
472
477
} */
473
478
474
479
result = OK;
480
+ return statusCode;
475
481
}
476
482
477
483
// Whole process to read the response from HTTP server.
0 commit comments