1 #include <HTTPSocket.h>
2 #include <SocketHandler.h>
5 class tSocket
: public HTTPSocket
8 tSocket(ISocketHandler
& h
, const std::string
& host
) : HTTPSocket(h
), m_host(host
)
15 Send("GET /index.html HTTP/1.0\r\n");
16 Send("Host: " + m_host
+ "\r\n");
23 void OnHeader(const std::string
& key
, const std::string
& value
) {
24 fprintf(stderr
, "%s: %s\n", key
.c_str(), value
.c_str());
27 void OnHeaderComplete() {
28 fprintf(stderr
, "\n");
31 void OnData(const char *buf
, size_t sz
) {
34 std::string str
= buf
;
36 printf("%s", str
.c_str());
43 fprintf(stderr
, "Content length: %d\n", m_sz
);
53 int main(int argc
, char *argv
[])
55 std::string host
= argc
> 1 ? argv
[1] : "www.alhem.net";
57 tSocket
sock(h
, host
);