summaryrefslogtreecommitdiffhomepage
path: root/NetEx/HttpClient.cpp
diff options
context:
space:
mode:
authorFWoltermann@gmail.com <FWoltermann@gmail.com@076cb2c4-205e-83fd-5cf3-1be9aa105544>2011-12-08 14:53:40 +0000
committerFWoltermann@gmail.com <FWoltermann@gmail.com@076cb2c4-205e-83fd-5cf3-1be9aa105544>2011-12-08 14:53:40 +0000
commite33e19d0587146859d48a134ec9fd94e7b7ba5cd (patch)
tree69d048c8801858d2756ab3a487090a7a1b74bf14 /NetEx/HttpClient.cpp
downloadstarshatter-e33e19d0587146859d48a134ec9fd94e7b7ba5cd.zip
starshatter-e33e19d0587146859d48a134ec9fd94e7b7ba5cd.tar.gz
starshatter-e33e19d0587146859d48a134ec9fd94e7b7ba5cd.tar.bz2
Initial upload
Diffstat (limited to 'NetEx/HttpClient.cpp')
-rw-r--r--NetEx/HttpClient.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/NetEx/HttpClient.cpp b/NetEx/HttpClient.cpp
new file mode 100644
index 0000000..3f7e204
--- /dev/null
+++ b/NetEx/HttpClient.cpp
@@ -0,0 +1,68 @@
+/* Project nGenEx
+ Destroyer Studios LLC
+ Copyright © 1997-2004. All Rights Reserved.
+
+ SUBSYSTEM: NetEx.lib
+ FILE: HttpClient.cpp
+ AUTHOR: John DiCamillo
+
+
+ OVERVIEW
+ ========
+ Network Server Pump for HTTP Server
+*/
+
+
+#include "MemDebug.h"
+#include "HttpClient.h"
+#include "NetHost.h"
+#include "NetLayer.h"
+#include <mmsystem.h>
+
+// +-------------------------------------------------------------------+
+
+HttpClient::HttpClient(const NetAddr& server_addr)
+ : NetClient(server_addr)
+{
+}
+
+HttpClient::~HttpClient()
+{
+ cookies.destroy();
+}
+
+HttpResponse*
+HttpClient::DoRequest(HttpRequest& request)
+{
+ // add existing cookies to request before sending:
+ CombineCookies(request.GetCookies(), cookies);
+
+ Text req = request.operator Text();
+ Text msg = SendRecv(req);
+ HttpResponse* response = new(__FILE__,__LINE__) HttpResponse(msg);
+
+ if (response) {
+ // save cookies returned in response:
+ CombineCookies(cookies, response->GetCookies());
+ }
+
+ return response;
+}
+
+void
+HttpClient::CombineCookies(List<HttpParam>& dst, List<HttpParam>& src)
+{
+ for (int i = 0; i < src.size(); i++) {
+ HttpParam* s = src[i];
+ HttpParam* d = dst.find(s);
+
+ if (d) {
+ d->value = s->value;
+ }
+ else {
+ HttpParam* cookie = new(__FILE__,__LINE__) HttpParam(s->name, s->value);
+ if (cookie)
+ dst.append(cookie);
+ }
+ }
+} \ No newline at end of file