]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_httpd.cpp
m_ssl_openssl is sending log messages and calling itself m_ssl_gnutls..
[user/henk/code/inspircd.git] / src / modules / m_httpd.cpp
index ec4aec43c04f61acd5a8c0545a7d4d17d5917303..f85046fd75713dfcd32696695f0658b4d998b1f9 100644 (file)
@@ -165,7 +165,6 @@ class HttpServerSocket : public BufferedSocket
 
                SendHeaders(data.length(), response, empty);
                this->Write(data);
-               this->FlushWriteBuffer();
        }
 
        void SendHeaders(unsigned long size, int response, HTTPHeaders &rheaders)
@@ -173,7 +172,7 @@ class HttpServerSocket : public BufferedSocket
 
                this->Write(http_version + " "+ConvToStr(response)+" "+Response(response)+"\r\n");
 
-               time_t local = this->Instance->Time();
+               time_t local = this->ServerInstance->Time();
                struct tm *timeinfo = gmtime(&local);
                char *date = asctime(timeinfo);
                date[strlen(date) - 1] = '\0';
@@ -216,7 +215,7 @@ class HttpServerSocket : public BufferedSocket
 
                        if (reqbuffer.length() >= 8192)
                        {
-                               Instance->Logs->Log("m_httpd",DEBUG, "m_httpd dropped connection due to an oversized request buffer");
+                               ServerInstance->Logs->Log("m_httpd",DEBUG, "m_httpd dropped connection due to an oversized request buffer");
                                reqbuffer.clear();
                                return false;
                        }
@@ -251,7 +250,6 @@ class HttpServerSocket : public BufferedSocket
                                if (request_type.empty() || uri.empty() || http_version.empty())
                                {
                                        SendHTTPError(400);
-                                       SetWrite();
                                        return;
                                }
 
@@ -265,7 +263,6 @@ class HttpServerSocket : public BufferedSocket
                        if ((fieldsep == std::string::npos) || (fieldsep == 0) || (fieldsep == cheader.length() - 1))
                        {
                                SendHTTPError(400);
-                               SetWrite();
                                return;
                        }
 
@@ -282,7 +279,6 @@ class HttpServerSocket : public BufferedSocket
                if ((http_version != "HTTP/1.1") && (http_version != "HTTP/1.0"))
                {
                        SendHTTPError(505);
-                       SetWrite();
                        return;
                }
 
@@ -319,48 +315,29 @@ class HttpServerSocket : public BufferedSocket
                        HTTPHeaders empty;
                        SendHeaders(index->ContentSize(), 200, empty);
                        this->Write(index->Contents());
-                       this->FlushWriteBuffer();
-                       SetWrite();
                }
                else
                {
                        claimed = false;
                        HTTPRequest httpr(request_type,uri,&headers,this,this->GetIP(),postdata);
                        Event acl((char*)&httpr, (Module*)HttpModule, "httpd_acl");
-                       acl.Send(this->Instance);
+                       acl.Send(this->ServerInstance);
                        if (!claimed)
                        {
                                Event e((char*)&httpr, (Module*)HttpModule, "httpd_url");
-                               e.Send(this->Instance);
+                               e.Send(this->ServerInstance);
                                if (!claimed)
                                {
                                        SendHTTPError(404);
-                                       SetWrite();
                                }
                        }
                }
        }
 
-
-       bool OnWriteReady()
-       {
-               Instance->Logs->Log("m_httpd",DEBUG,"OnWriteReady()");
-               return false;
-       }
-
        void Page(std::stringstream* n, int response, HTTPHeaders *hheaders)
        {
                SendHeaders(n->str().length(), response, *hheaders);
                this->Write(n->str());
-               this->FlushWriteBuffer();
-               SetWrite();
-       }
-
-       void SetWrite()
-       {
-               Instance->Logs->Log("m_httpd",DEBUG,"SetWrite()");
-               this->WaitingForWriteEvent = true;
-               Instance->SE->WantWrite(this);
        }
 };
 
@@ -371,14 +348,14 @@ class HttpListener : public ListenSocketBase
        FileReader* index;
 
  public:
-       HttpListener(InspIRCd* Instance, FileReader *idx, int port, char* addr) : ListenSocketBase(Instance, port, addr)
+       HttpListener(InspIRCd* Instance, FileReader *idx, int port, const std::string &addr) : ListenSocketBase(Instance, port, addr)
        {
                this->index = idx;
        }
 
        virtual void OnAcceptReady(const std::string &ipconnectedto, int nfd, const std::string &incomingip)
        {
-               new HttpServerSocket(ServerInstance, nfd, (char *)incomingip.c_str(), index); // XXX unsafe casts suck
+               new HttpServerSocket(ServerInstance, nfd, (char *)incomingip.c_str(), index); // ugly cast courtesy of bufferedsocket
        }
 };