Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
HttpClient.cpp
Go to the documentation of this file.
1
/* Project nGenEx
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: NetEx.lib
6
FILE: HttpClient.cpp
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Network Server Pump for HTTP Server
13
*/
14
15
16
#include "
MemDebug.h
"
17
#include "
HttpClient.h
"
18
#include "
NetHost.h
"
19
#include "
NetLayer.h
"
20
#include <mmsystem.h>
21
22
// +-------------------------------------------------------------------+
23
24
HttpClient::HttpClient
(
const
NetAddr
& server_addr)
25
:
NetClient
(server_addr)
26
{
27
}
28
29
HttpClient::~HttpClient
()
30
{
31
cookies
.
destroy
();
32
}
33
34
HttpResponse
*
35
HttpClient::DoRequest
(
HttpRequest
& request)
36
{
37
// add existing cookies to request before sending:
38
CombineCookies
(request.
GetCookies
(),
cookies
);
39
40
Text
req = request.operator
Text
();
41
Text
msg =
SendRecv
(req);
42
HttpResponse
* response =
new
(__FILE__,__LINE__)
HttpResponse
(msg);
43
44
if
(response) {
45
// save cookies returned in response:
46
CombineCookies
(
cookies
, response->
GetCookies
());
47
}
48
49
return
response;
50
}
51
52
void
53
HttpClient::CombineCookies
(
List<HttpParam>
& dst,
List<HttpParam>
& src)
54
{
55
for
(
int
i = 0; i < src.
size
(); i++) {
56
HttpParam
* s = src[i];
57
HttpParam
* d = dst.
find
(s);
58
59
if
(d) {
60
d->
value
= s->
value
;
61
}
62
else
{
63
HttpParam
* cookie =
new
(__FILE__,__LINE__)
HttpParam
(s->
name
, s->
value
);
64
if
(cookie)
65
dst.
append
(cookie);
66
}
67
}
68
}
NetEx
HttpClient.cpp
Generated on Tue Jun 5 2012 20:46:17 for Starshatter_Open by
1.8.1