SendHeaders(data.length(), response, empty);
this->Write(data);
- this->FlushWriteBuffer();
}
void SendHeaders(unsigned long size, int response, HTTPHeaders &rheaders)
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';
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;
}
if (request_type.empty() || uri.empty() || http_version.empty())
{
SendHTTPError(400);
- SetWrite();
return;
}
if ((fieldsep == std::string::npos) || (fieldsep == 0) || (fieldsep == cheader.length() - 1))
{
SendHTTPError(400);
- SetWrite();
return;
}
if ((http_version != "HTTP/1.1") && (http_version != "HTTP/1.0"))
{
SendHTTPError(505);
- SetWrite();
return;
}
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);
}
};
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
}
};