void MediaHTTPConnection::start(void) { TCPConnection::start(); // start HTTP connection if (isConnected() && socket().is_open()) { state = STATE_OPEN; /* notify our observers about new connection; notify(); */ BLITZ_LOG_INFO("got connection from: %s, from port:%d", getRemoteIP().c_str(), getRemotePort()); // Set a deadline for receiving HTTP headers. m_io_control_timer.expires_from_now(boost::posix_time::seconds(MediaHTTPConnection::receive_timeout)); boost::asio::async_read_until(socket(), m_response, "\r\n\r\n", boost::bind(&MediaHTTPConnection::handleReadHeader, this, boost::asio::placeholders::error)); m_io_control_timer.async_wait(boost::bind(&MediaHTTPConnection::handleTimeoutOnSocket, this, boost::asio::placeholders::error)); } }
/* * Sends a request of a resource(URI) using DELETE method */ void HTTP::sendRequestDELETE(int sk,char* resource) { char host[16];getRemoteIP(host); char* headers[1];headers[0]="Host: ";strcat(headers[0],host); sendRequestGET(sk,headers,1,resource); }
/* * Sends a request of a resource(URI) using PUT method: * Like POST method. */ void HTTP::sendRequestPUT(int sk,char* resource,char* data) { char host[16];getRemoteIP(host); char* headers[1];headers[0]="Host: ";strcat(headers[0],host); sendRequestPUT(sk,headers,1,resource,data); }