Files
i2psam/eepget.cpp

36 lines
829 B
C++
Raw Normal View History

2022-06-08 18:16:14 +01:00
/**
* Copyright (c) 2017 The I2P Project
*
* Distributed under the MIT software license, see the accompanying
* file LICENSE or http://www.opensource.org/licenses/mit-license.php.
*
2022-06-09 10:30:29 +00:00
* See full documentation about SAM at http://www.i2p2.i2p/samv3.html
2022-06-08 18:16:14 +01:00
*/
2017-04-02 11:34:23 +12:00
#include "i2psam.h"
int main(int argc, char **argv)
{
2022-06-09 10:30:29 +00:00
if (argc < 2)
{
std::cerr << "Usage: eepget <hostname.i2p>" << std::endl;
return 1;
2017-04-02 11:34:23 +12:00
}
2022-06-09 10:30:29 +00:00
std::string target(argv[1]);
SAM::StreamSession s("eepget");
auto lookupResult = s.namingLookup(target);
auto connResult = s.connect(lookupResult.value, false);
auto conn = connResult.value.get();
conn->write("GET / HTTP/1.1\r\n\r\n");
auto reply = conn->read();
while (!reply.empty())
{
std::cout << reply << std::flush;
reply = conn->read();
2017-04-02 11:34:23 +12:00
}
2022-06-09 10:30:29 +00:00
conn->close();
2017-04-02 11:34:23 +12:00
}