]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_httpd.cpp
Make User:: nick/ident/dhost/fullname and some other things std::string instead of...
[user/henk/code/inspircd.git] / src / modules / m_httpd.cpp
index eff9a7ad238f38f7423cf328a98c3a46738550f1..7c93a70b609418255da3bccd81854775039463f4 100644 (file)
@@ -180,6 +180,7 @@ class HttpServerSocket : public BufferedSocket
                
                SendHeaders(data.length(), response, empty);
                this->Write(data);
+               this->FlushWriteBuffer();
        }
        
        void SendHeaders(unsigned long size, int response, HTTPHeaders &rheaders)
@@ -265,7 +266,7 @@ class HttpServerSocket : public BufferedSocket
                                if (request_type.empty() || uri.empty() || http_version.empty())
                                {
                                        SendHTTPError(400);
-                                       Instance->SE->WantWrite(this);
+                                       SetWrite();
                                        return;
                                }
                                
@@ -279,7 +280,7 @@ class HttpServerSocket : public BufferedSocket
                        if ((fieldsep == std::string::npos) || (fieldsep == 0) || (fieldsep == cheader.length() - 1))
                        {
                                SendHTTPError(400);
-                               Instance->SE->WantWrite(this);
+                               SetWrite();
                                return;
                        }
                        
@@ -296,7 +297,7 @@ class HttpServerSocket : public BufferedSocket
                if ((http_version != "HTTP/1.1") && (http_version != "HTTP/1.0"))
                {
                        SendHTTPError(505);
-                       Instance->SE->WantWrite(this);
+                       SetWrite();
                        return;
                }
        
@@ -333,18 +334,24 @@ class HttpServerSocket : public BufferedSocket
                        HTTPHeaders empty;
                        SendHeaders(index->ContentSize(), 200, empty);
                        this->Write(index->Contents());
-                       Instance->SE->WantWrite(this);
+                       this->FlushWriteBuffer();
+                       SetWrite();
                }
                else
                {
                        claimed = false;
                        HTTPRequest httpr(request_type,uri,&headers,this,this->GetIP(),postdata);
-                       Event e((char*)&httpr, (Module*)HttpModule, "httpd_url");
-                       e.Send(this->Instance);
+                       Event acl((char*)&httpr, (Module*)HttpModule, "httpd_acl");
+                       acl.Send(this->Instance);
                        if (!claimed)
                        {
-                               SendHTTPError(404);
-                               Instance->SE->WantWrite(this);
+                               Event e((char*)&httpr, (Module*)HttpModule, "httpd_url");
+                               e.Send(this->Instance);
+                               if (!claimed)
+                               {
+                                       SendHTTPError(404);
+                                       SetWrite();
+                               }
                        }
                }
        }
@@ -352,6 +359,7 @@ class HttpServerSocket : public BufferedSocket
 
        bool OnWriteReady()
        {
+               Instance->Logs->Log("m_httpd",DEBUG,"OnWriteReady()");
                return false;
        }
 
@@ -359,6 +367,14 @@ class HttpServerSocket : public BufferedSocket
        {
                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);
        }
 };