void CGeneralAgentHttpServer::GenerateDocument() { std::string strSendBuf = "CGeneralAgentHttpServer.\n\r"; strSendBuf += GetHttpDate()+"\r\n"; strSendBuf += "Your Body:["+m_strBody+"]\r\n"; Send(strSendBuf); SetCloseAndDelete(); }
void HttpdSocket::OnHeaderComplete() { m_cookies = new HttpdCookies(m_http_cookie); if (GetMethod() == "GET") { Utility::SetEnv("QUERY_STRING", GetQueryString()); } Utility::SetEnv("REQUEST_METHOD", GetMethod()); Utility::SetEnv("HTTP_COOKIE", m_http_cookie); Utility::SetEnv("CONTENT_TYPE", m_content_type); Utility::SetEnv("CONTENT_LENGTH", m_content_length_str); if (GetMethod() == "POST") { m_file = new MemFile; } else if (GetMethod() == "GET") { m_form = new HttpdForm(GetQueryString(), GetQueryString().size() ); AddResponseHeader("Date", datetime2httpdate(GetDate()) ); if (GetUri() == "/image") { Send64(Utility::Logo, "image/png"); } else { Exec(); } Reset(); // prepare for next request } else { AddResponseHeader("Date", GetHttpDate()); AddResponseHeader("Connection", "close"); SetStatus("405"); SetStatusText("Method not allowed"); SendResponse(); } }
void HttpdSocket::OnHeaderComplete() { m_cookies = new HttpdCookies(m_http_cookie); #if (defined(SOLARIS8) || defined(SOLARIS)) { char slask[1000]; if (GetMethod() == "GET") { sprintf(slask,"QUERY_STRING=%s", GetQueryString().c_str()); putenv(slask); } sprintf(slask,"REQUEST_METHOD=%s", GetMethod().c_str()); putenv(slask); sprintf(slask,"HTTP_COOKIE=%s", m_http_cookie.c_str()); putenv(slask); sprintf(slask,"CONTENT_TYPE=%s", m_content_type.c_str()); putenv(slask); sprintf(slask,"CONTENT_LENGTH=%s", m_content_length_str.c_str()); putenv(slask); } #elif defined _WIN32 { char slask[1000]; if (GetMethod() == "GET") { sprintf(slask,"QUERY_STRING=%s", GetQueryString().c_str()); _putenv(slask); } sprintf(slask,"REQUEST_METHOD=%s", GetMethod().c_str()); _putenv(slask); sprintf(slask,"HTTP_COOKIE=%s", m_http_cookie.c_str()); _putenv(slask); sprintf(slask,"CONTENT_TYPE=%s", m_content_type.c_str()); _putenv(slask); sprintf(slask,"CONTENT_LENGTH=%s", m_content_length_str.c_str()); _putenv(slask); } #else if (GetMethod() == "GET") { setenv("QUERY_STRING", GetQueryString().c_str(), 1); } setenv("REQUEST_METHOD", GetMethod().c_str(), 1); setenv("HTTP_COOKIE", m_http_cookie.c_str(), 1); setenv("CONTENT_TYPE", m_content_type.c_str(), 1); setenv("CONTENT_LENGTH", m_content_length_str.c_str(), 1); #endif if (GetMethod() == "POST") { m_file = new MemFile; } else if (GetMethod() == "GET") { m_form = new HttpdForm(GetQueryString(), GetQueryString().size() ); AddResponseHeader("Date", datetime2httpdate(GetDate()) ); Exec(); Reset(); // prepare for next request } else { AddResponseHeader("Date", GetHttpDate()); AddResponseHeader("Connection", "close"); SetStatus("405"); SetStatusText("Method not allowed"); SendResponse(); } }