@@ -14,6 +14,13 @@ namespace gameanalytics
1414{
1515 namespace http
1616 {
17+ constexpr int HTTP_RESPONSE_OK = 200 ;
18+ constexpr int HTTP_RESPONSE_CREATED = 201 ;
19+ constexpr int HTTP_RESPONSE_NO_CONTENT = 204 ;
20+ constexpr int HTTP_RESPONSE_BAD_REQUEST = 400 ;
21+ constexpr int HTTP_RESPONSE_UNAUTHORIZED = 401 ;
22+ constexpr int HTTP_RESPONSE_INTERNAL_ERROR = 500 ;
23+
1724 size_t writefunc (void *ptr, size_t size, size_t nmemb, ResponseData *s)
1825 {
1926 const size_t new_len = s->packet .size () + size * nmemb + 1 ;
@@ -364,7 +371,7 @@ namespace gameanalytics
364371 logging::GALogger::d (" sdk error content : %s" , s.toString ().c_str ());;
365372
366373 // if not 200 result
367- if (statusCode != 200 && statusCode != 204 )
374+ if (statusCode != HTTP_RESPONSE_OK && statusCode != HTTP_RESPONSE_NO_CONTENT )
368375 {
369376 logging::GALogger::d (" sdk error failed. response code not 200 or 204. status code: %u" , CURLE_OK);
370377 return ;
@@ -438,21 +445,21 @@ namespace gameanalytics
438445 }
439446
440447 // ok
441- if (statusCode == 200 )
448+ if (statusCode == HTTP_RESPONSE_OK )
442449 {
443450 return Ok;
444451 }
445- if (statusCode == 201 )
452+ if (statusCode == HTTP_RESPONSE_CREATED )
446453 {
447454 return Created;
448455 }
449- if (statusCode == 204 )
456+ if (statusCode == HTTP_RESPONSE_NO_CONTENT )
450457 {
451458 return NoContent;
452459 }
453460
454461 // 401 can return 0 status
455- if (statusCode == 0 || statusCode == 401 )
462+ if (statusCode == 0 || statusCode == HTTP_RESPONSE_UNAUTHORIZED )
456463 {
457464 logging::GALogger::d (" %s request. 401 - Unauthorized." , requestId);
458465 return Unauthorized;
@@ -464,7 +471,7 @@ namespace gameanalytics
464471 return BadRequest;
465472 }
466473
467- if (statusCode == 500 )
474+ if (statusCode == HTTP_RESPONSE_INTERNAL_ERROR )
468475 {
469476 logging::GALogger::d (" %s request. 500 - Internal Server Error." , requestId);
470477 return InternalServerError;
0 commit comments