From 419e301b09de1935ab61f9a28363bb375fc7e208 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sun, 2 Aug 2015 20:42:43 +0000 Subject: Steam: - fixed bug with default group creation - added HttpResponse - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@14824 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Steam/src/http_request.h | 55 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'protocols/Steam/src/http_request.h') diff --git a/protocols/Steam/src/http_request.h b/protocols/Steam/src/http_request.h index 73fce0eb1b..35a6352d42 100644 --- a/protocols/Steam/src/http_request.h +++ b/protocols/Steam/src/http_request.h @@ -1,6 +1,51 @@ #ifndef _HTTP_REQUEST_H_ #define _HTTP_REQUEST_H_ +class HttpResponse : public NETLIBHTTPREQUEST, public MZeroedObject +{ +public: + const NETLIBHTTPREQUEST* request; + + HttpResponse(const NETLIBHTTPREQUEST* response, const NETLIBHTTPREQUEST* request = NULL) + { + request = request; + if (response) + { + cbSize = response->cbSize; + requestType = response->requestType; + flags = response->flags; + szUrl = mir_strdup(response->szUrl); + headers = (NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER) * response->headersCount); + headersCount = response->headersCount; + for (int i = 0; i < headersCount; i++) + { + headers[i].szName = mir_strdup(response->headers[i].szName); + headers[i].szValue = mir_strdup(response->headers[i].szValue); + } + pData = (char*)mir_alloc(response->dataLength); + dataLength = response->dataLength; + memcpy(pData, response->pData, dataLength); + resultCode = response->resultCode; + szResultDescr = mir_strdup(response->szResultDescr); + nlc = response->nlc; + timeout = response->timeout; + } + } + + ~HttpResponse() + { + for (int i = 0; i < headersCount; i++) + { + mir_free(headers[i].szName); + mir_free(headers[i].szValue); + } + mir_free(szUrl); + mir_free(headers); + mir_free(pData); + mir_free(szResultDescr); + } +}; + class HttpRequest : public NETLIBHTTPREQUEST, public MZeroedObject { private: @@ -81,7 +126,7 @@ public: mir_free(pData); } - NETLIBHTTPREQUEST* Send(HANDLE hConnection) + HttpResponse* Send(HANDLE hConnection) { szUrl = m_url.GetBuffer(); @@ -89,8 +134,14 @@ public: mir_snprintf(message, _countof(message), "Send request to %s", szUrl); CallService(MS_NETLIB_LOG, (WPARAM)hConnection, (LPARAM)&message); - return (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hConnection, (LPARAM)this); + NETLIBHTTPREQUEST* response = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hConnection, (LPARAM)this); + HttpResponse* result = new HttpResponse(response, this); + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response); + + return result; } }; + + #endif //_HTTP_REQUEST_H_ \ No newline at end of file -- cgit v1.2.3