summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/steam_request.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-12-12 21:56:51 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-12-12 21:56:51 +0300
commite9a3b54db4aa8ffb6f97baabc2b676e3d9570bb1 (patch)
treeff76b25d2c458630483fb57fc7383df10e8c0001 /protocols/Steam/src/steam_request.cpp
parentf1a5f02b05bae013e1c7773328b773565031b3c6 (diff)
more code cleaning
Diffstat (limited to 'protocols/Steam/src/steam_request.cpp')
-rw-r--r--protocols/Steam/src/steam_request.cpp44
1 files changed, 27 insertions, 17 deletions
diff --git a/protocols/Steam/src/steam_request.cpp b/protocols/Steam/src/steam_request.cpp
index 918e01ca16..47755ab548 100644
--- a/protocols/Steam/src/steam_request.cpp
+++ b/protocols/Steam/src/steam_request.cpp
@@ -2,37 +2,47 @@
bool CSteamProto::SendRequest(HttpRequest *request)
{
- auto *pResp = Netlib_HttpTransaction(m_hNetlibUser, request->Get());
- HttpResponse response(pResp);
- delete request;
- return response.IsSuccess();
+ if (auto *pResp = Netlib_HttpTransaction(m_hNetlibUser, request->Get())) {
+ bool bSuccess = pResp->resultCode == 200;
+ delete pResp;
+ return bSuccess;
+ }
+ return false;
}
bool CSteamProto::SendRequest(HttpRequest *request, HttpCallback callback, void *param)
{
- auto *pResp = Netlib_HttpTransaction(m_hNetlibUser, request->Get());
- HttpResponse response(pResp);
- if (callback)
- (this->*callback)(response, param);
- delete request;
- return response.IsSuccess();
+ if (auto *pResp = Netlib_HttpTransaction(m_hNetlibUser, request->Get())) {
+ bool bSuccess = pResp->resultCode == 200;
+ if (callback)
+ (this->*callback)(*pResp, param);
+ delete request;
+ delete pResp;
+ return bSuccess;
+ }
+ return false;
}
bool CSteamProto::SendRequest(HttpRequest *request, JsonCallback callback, void *param)
{
- auto *pResp = Netlib_HttpTransaction(m_hNetlibUser, request->Get());
- HttpResponse response(pResp);
- if (callback) {
- JSONNode root = JSONNode::parse(response.data());
- (this->*callback)(root, param);
+ if (auto *pResp = Netlib_HttpTransaction(m_hNetlibUser, request->Get())) {
+ bool bSuccess = pResp->resultCode == 200;
+ if (callback) {
+ JSONNode root = JSONNode::parse(pResp->body);
+ (this->*callback)(root, param);
+ }
+ delete request;
+ delete pResp;
+ return bSuccess;
}
- delete request;
- return response.IsSuccess();
+ return false;
}
/////////////////////////////////////////////////////////////////////////////////////////
// HttpRequest
+#define STEAM_USER_AGENT "Valve/Steam HTTP Client 1.0"
+
HttpRequest::HttpRequest(int iRequestType, const char *szUrl)
{
flags = NLHRF_SSL | NLHRF_HTTP11 | NLHRF_REDIRECT | NLHRF_DUMPASTEXT;