X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fhttpd.h;h=56fd22da03820a166f63b03ee6695426f2184168;hb=e6601069038c35c546fd3f3dce95024b0d13f1b4;hp=2d8da2cbdb81b4f1f3d0264942d5835eff5189ba;hpb=d185decae97752368d5cf62311cbc0d1a52aa22c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/httpd.h b/src/modules/httpd.h index 2d8da2cbd..56fd22da0 100644 --- a/src/modules/httpd.h +++ b/src/modules/httpd.h @@ -1,20 +1,30 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2008 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits + * Copyright (C) 2009 Daniel De Graaf + * Copyright (C) 2008 Pippijn van Steenhoven + * Copyright (C) 2007 John Brooks + * Copyright (C) 2007 Dennis Friis + * Copyright (C) 2006 Craig Edwards * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + #include "base.h" -#ifndef __HTTPD_H__ -#define __HTTPD_H__ +#ifndef HTTPD_H +#define HTTPD_H #include #include @@ -22,7 +32,7 @@ /** A modifyable list of HTTP header fields */ -class HTTPHeaders : public classbase +class HTTPHeaders { protected: std::map headers; @@ -94,11 +104,11 @@ class HTTPHeaders : public classbase } }; +class HttpServerSocket; + /** This class represents a HTTP request. - * It will be sent to all modules as the data section of - * an Event. */ -class HTTPRequest : public classbase +class HTTPRequest : public Event { protected: std::string type; @@ -114,7 +124,7 @@ class HTTPRequest : public classbase /** A socket pointer, which you must return in your HTTPDocument class * if you reply to this request. */ - void* sock; + HttpServerSocket* sock; /** Initialize HTTPRequest. * This constructor is called by m_httpd.so to initialize the class. @@ -125,8 +135,9 @@ class HTTPRequest : public classbase * @param ip The IP address making the web request. * @param pdata The post data (content after headers) received with the request, up to Content-Length in size */ - HTTPRequest(const std::string &request_type, const std::string &uri, HTTPHeaders* hdr, void* opaque, const std::string &ip, const std::string &pdata) - : type(request_type), document(uri), ipaddr(ip), postdata(pdata), headers(hdr), sock(opaque) + HTTPRequest(Module* me, const std::string &eventid, const std::string &request_type, const std::string &uri, + HTTPHeaders* hdr, HttpServerSocket* socket, const std::string &ip, const std::string &pdata) + : Event(me, eventid), type(request_type), document(uri), ipaddr(ip), postdata(pdata), headers(hdr), sock(socket) { } @@ -171,20 +182,13 @@ class HTTPRequest : public classbase * When you initialize this class you may initialize it with all components required to * form a valid HTTP response, including document data, headers, and a response code. */ -class HTTPDocument : public classbase +class HTTPDocumentResponse : public Request { - protected: - + public: std::stringstream* document; int responsecode; - - public: - HTTPHeaders headers; - - /** The socket pointer from an earlier HTTPRequest - */ - void* sock; + HTTPRequest& src; /** Initialize a HTTPRequest ready for sending to m_httpd.so. * @param opaque The socket pointer you obtained from the HTTPRequest at an earlier time @@ -193,32 +197,9 @@ class HTTPDocument : public classbase * based upon the response code. * @param extra Any extra headers to include with the defaults, seperated by carriage return and linefeed. */ - HTTPDocument(void* opaque, std::stringstream* doc, int response) : document(doc), responsecode(response), sock(opaque) - { - } - - /** Get the document text. - * @return The document text - */ - std::stringstream* GetDocument() - { - return this->document; - } - - /** Get the document size. - * @return the size of the document text in bytes - */ - unsigned long GetDocumentSize() - { - return this->document->str().length(); - } - - /** Get the response code. - * @return The response code - */ - int GetResponseCode() + HTTPDocumentResponse(Module* me, HTTPRequest& req, std::stringstream* doc, int response) + : Request(me, req.source, "HTTP-DOC"), document(doc), responsecode(response), src(req) { - return this->responsecode; } };