summaryrefslogtreecommitdiff
path: root/src/modules/m_http_client.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-07 17:27:11 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-07 17:27:11 +0000
commit2458d30566c36b23a204327872961645634ef57b (patch)
tree4b085a50c1e6ea4edba576f8c85149ef5d8ffdf7 /src/modules/m_http_client.cpp
parent34f4ee851c1822696612dadd4a46194f9ed28987 (diff)
Rename all the classes in m_httpd to be HttpServer etc,
Make a copy of the request in the http client so we dont need to leave pointers hanging around in the requestor module git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6246 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_http_client.cpp')
-rw-r--r--src/modules/m_http_client.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/modules/m_http_client.cpp b/src/modules/m_http_client.cpp
index 9004b202b..9fdd75b14 100644
--- a/src/modules/m_http_client.cpp
+++ b/src/modules/m_http_client.cpp
@@ -34,7 +34,7 @@ class HTTPSocket : public InspSocket
private:
InspIRCd *Server;
class ModuleHTTPClient *Mod;
- HTTPClientRequest *req;
+ HTTPClientRequest req;
HTTPClientResponse *response;
URL url;
enum { HTTP_CLOSED, HTTP_REQSENT, HTTP_HEADERS, HTTP_DATA } status;
@@ -134,9 +134,14 @@ HTTPSocket::~HTTPSocket()
bool HTTPSocket::DoRequest(HTTPClientRequest *req)
{
- this->req = req;
-
- if (!ParseURL(req->GetURL()))
+ /* Tweak by brain - we take a copy of this,
+ * so that the caller doesnt need to leave
+ * pointers knocking around, less chance of
+ * a memory leak.
+ */
+ this->req = *req;
+
+ if (!ParseURL(this->req.GetURL()))
return false;
this->port = url.port;
@@ -234,7 +239,7 @@ bool HTTPSocket::OnConnected()
std::string request = "GET " + url.request + " HTTP/1.1\r\n";
// Dump headers into the request
- HeaderMap headers = req->GetHeaders();
+ HeaderMap headers = req.GetHeaders();
for (HeaderMap::iterator i = headers.begin(); i != headers.end(); i++)
request += i->first + ": " + i->second + "\r\n";
@@ -280,7 +285,7 @@ bool HTTPSocket::OnDataReady()
{
// HTTP reply (HTTP/1.1 200 msg)
data += 9;
- response = new HTTPClientResponse((Module*)Mod, req->GetSource() , url.url, atoi(data), data + 4);
+ response = new HTTPClientResponse((Module*)Mod, req.GetSource() , url.url, atoi(data), data + 4);
this->status = HTTP_HEADERS;
continue;
}