From d2a83c7d22df33abd1678756fd4caba432700860 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sun, 22 Mar 2015 21:07:19 +0000 Subject: SkypeWeb: - refactored HttpRequest 2 - status changing support (patch from MikalaiR) git-svn-id: http://svn.miranda-ng.org/main/trunk@12478 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/http_request.h | 81 ++++++++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 6 deletions(-) (limited to 'protocols/SkypeWeb/src/http_request.h') diff --git a/protocols/SkypeWeb/src/http_request.h b/protocols/SkypeWeb/src/http_request.h index 28b34c075d..5d34d04e3f 100644 --- a/protocols/SkypeWeb/src/http_request.h +++ b/protocols/SkypeWeb/src/http_request.h @@ -171,19 +171,14 @@ protected: HttpRequest() : Headers(*this) { cbSize = sizeof(NETLIBHTTPREQUEST); + flags = NLHRF_HTTP11 | NLHRF_NODUMPSEND | NLHRF_DUMPASTEXT; } HttpRequest(int httpMethod, LPCSTR urlFormat, va_list args) : Headers(*this) { - this->HttpRequest::HttpRequest(); - requestType = httpMethod; - flags = NLHRF_HTTP11 | NLHRF_NODUMPSEND | NLHRF_DUMPASTEXT; - Url.content.AppendFormatV(urlFormat, args); - if (Url.content.Find("://") == -1) - Url.content.Insert(0, flags & NLHRF_SSL ? "https://" : "http://"); } public: @@ -213,6 +208,8 @@ public: NETLIBHTTPREQUEST * Send(HANDLE hConnection) { + if (Url.content.Find("://") == -1) + Url.content.Insert(0, flags & NLHRF_SSL ? "https://" : "http://"); szUrl = Url.ToString(); pData = Body.ToString(); @@ -226,4 +223,76 @@ public: } }; +class HttpGetRequest : public HttpRequest +{ +public: + HttpGetRequest(LPCSTR urlFormat, ...) + { + va_list args; + va_start(args, urlFormat); + this->HttpRequest::HttpRequest(REQUEST_GET, urlFormat, args); + va_end(args); + } +}; + +class HttpPostRequest : public HttpRequest +{ +public: + HttpPostRequest(LPCSTR urlFormat, ...) + { + va_list args; + va_start(args, urlFormat); + this->HttpRequest::HttpRequest(REQUEST_POST, urlFormat, args); + va_end(args); + + Headers << CHAR_VALUE("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); + } +}; + +class HttpsRequest : public HttpRequest +{ +protected: + HttpsRequest() : HttpRequest() + { + flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMPSEND | NLHRF_DUMPASTEXT; + } + +public: + HttpsRequest(int type, LPCSTR urlFormat, ...) + { + va_list args; + va_start(args, urlFormat); + this->HttpRequest::HttpRequest(type, urlFormat, args); + va_end(args); + + flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMPSEND | NLHRF_DUMPASTEXT; + } +}; + +class HttpsGetRequest : public HttpsRequest +{ +public: + HttpsGetRequest(LPCSTR urlFormat, ...) + { + va_list args; + va_start(args, urlFormat); + this->HttpRequest::HttpRequest(REQUEST_GET, urlFormat, args); + va_end(args); + } +}; + +class HttpsPostRequest : public HttpsRequest +{ +public: + HttpsPostRequest(LPCSTR urlFormat, ...) + { + va_list args; + va_start(args, urlFormat); + this->HttpsRequest::HttpsRequest(REQUEST_POST, urlFormat, args); + va_end(args); + + Headers << CHAR_VALUE("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); + } +}; + #endif //_HTTP_REQUEST_H_ \ No newline at end of file -- cgit v1.2.3