mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 11:04:00 +01:00
Prepare support for POST/PUT
This commit is contained in:
parent
9ee049aa63
commit
bff3d8f5c1
|
@ -323,8 +323,12 @@ namespace util
|
|||
}
|
||||
s << "<p><a href=\"zmw2cyw2vj7f6obx3msmdvdepdhnw2ctc4okza2zjxlukkdfckhq\">Flibusta</a></p>";
|
||||
}
|
||||
|
||||
void HTTPConnection::HandleDestinationRequest (const std::string& address, const std::string& uri)
|
||||
{
|
||||
HandleDestinationRequest(address, "GET", "", uri);
|
||||
}
|
||||
|
||||
void HTTPConnection::HandleDestinationRequest (const std::string& address, const std::string& method, const std::string& data, const std::string& uri)
|
||||
{
|
||||
i2p::data::IdentHash destination;
|
||||
std::string fullAddress;
|
||||
|
@ -380,7 +384,13 @@ namespace util
|
|||
m_Stream = i2p::stream::CreateStream (*leaseSet);
|
||||
if (m_Stream)
|
||||
{
|
||||
std::string request = "GET " + uri + " HTTP/1.1\n Host:" + fullAddress + "\n";
|
||||
std::string request = method+" " + uri + " HTTP/1.1\n Host:" + fullAddress + "\r\n";
|
||||
if (!strcmp(method.c_str(), "GET"))
|
||||
{
|
||||
// POST/PUT, apply body
|
||||
request += "\r\n"+ data;
|
||||
}
|
||||
LogPrint("HTTP Client Request: ", request);
|
||||
m_Stream->Send ((uint8_t *)request.c_str (), request.length (), 10);
|
||||
AsyncStreamReceive ();
|
||||
}
|
||||
|
@ -421,7 +431,7 @@ namespace util
|
|||
m_Reply.headers[1].value = "text/html";
|
||||
|
||||
boost::asio::async_write (*m_Socket, m_Reply.to_buffers(status),
|
||||
boost::bind (&HTTPConnection::HandleWriteReply, this,
|
||||
boost::bind (&HTTPConnection::HandleWriteReply, this,
|
||||
boost::asio::placeholders::error));
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,9 @@ namespace util
|
|||
|
||||
protected:
|
||||
|
||||
|
||||
virtual void HandleDestinationRequest(const std::string& address, const std::string& uri);
|
||||
virtual void HandleDestinationRequest(const std::string& address, const std::string& method, const std::string& data, const std::string& uri);
|
||||
virtual void RunRequest ();
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue