![]() |
HttpGetSocket Class ReferenceGet http page.
More...
|
Public Member Functions | |
HttpGetSocket (ISocketHandler &) | |
HttpGetSocket (ISocketHandler &, const std::string &url, const std::string &to_file="", bool connect=true) | |
HttpGetSocket (ISocketHandler &, const std::string &host, port_t port, const std::string &url, const std::string &to_file="", bool connect=true) | |
~HttpGetSocket () | |
void | DoConnect () |
void | DoConnect (const std::string &host, unsigned short port) |
void | OnConnect () |
Called when a connection has completed. | |
Protected Member Functions | |
HttpGetSocket & | operator= (const HttpGetSocket &) |
HttpGetSocket (const HttpGetSocket &s) |
Definition at line 45 of file HttpGetSocket.h.
HttpGetSocket::HttpGetSocket | ( | ISocketHandler & | h | ) |
HttpGetSocket::HttpGetSocket | ( | ISocketHandler & | h, | |
const std::string & | url, | |||
const std::string & | to_file = "" , |
|||
bool | connect = true | |||
) |
Definition at line 53 of file HttpGetSocket.cpp.
References DoConnect(), and HttpClientSocket::SetFilename().
00053 : HttpClientSocket(h, url_in) 00054 { 00055 if (to_file.size()) 00056 { 00057 SetFilename(to_file); 00058 } 00059 if (connect) 00060 DoConnect(); 00061 }
HttpGetSocket::HttpGetSocket | ( | ISocketHandler & | h, | |
const std::string & | host, | |||
port_t | port, | |||
const std::string & | url, | |||
const std::string & | to_file = "" , |
|||
bool | connect = true | |||
) |
Definition at line 83 of file HttpGetSocket.cpp.
References DoConnect(), HttpClientSocket::SetFilename(), and HTTPSocket::SetUrl().
00083 : HttpClientSocket(h, host, port, url) 00084 { 00085 SetUrl(url); 00086 if (to_file.size()) 00087 { 00088 SetFilename(to_file); 00089 } 00090 if (connect) 00091 DoConnect(host, port); 00092 }
HttpGetSocket::~HttpGetSocket | ( | ) |
HttpGetSocket::HttpGetSocket | ( | const HttpGetSocket & | s | ) | [inline, protected] |
void HttpGetSocket::DoConnect | ( | ) |
Definition at line 64 of file HttpGetSocket.cpp.
References HttpClientSocket::GetUrlHost(), and HttpClientSocket::GetUrlPort().
Referenced by HttpGetSocket().
00065 { 00066 DoConnect(GetUrlHost(), GetUrlPort()); 00067 }
void HttpGetSocket::DoConnect | ( | const std::string & | host, | |
unsigned short | port | |||
) |
Definition at line 70 of file HttpGetSocket.cpp.
References StreamSocket::Connecting(), Socket::Handler(), LOG_LEVEL_FATAL, ISocketHandler::LogError(), TcpSocket::Open(), and Socket::SetCloseAndDelete().
00071 { 00072 if (!Open(host, port)) 00073 { 00074 if (!Connecting()) 00075 { 00076 Handler().LogError(this, "HttpGetSocket", -1, "connect() failed miserably", LOG_LEVEL_FATAL); 00077 SetCloseAndDelete(); 00078 } 00079 } 00080 }
void HttpGetSocket::OnConnect | ( | ) | [virtual] |
Called when a connection has completed.
Reimplemented from Socket.
Definition at line 100 of file HttpGetSocket.cpp.
References HTTPSocket::AddResponseHeader(), HttpClientSocket::GetUrlHost(), HttpClientSocket::GetUrlPort(), Utility::l2string(), HTTPSocket::MyUseragent(), HTTPSocket::SendRequest(), and HTTPSocket::SetMethod().
00101 { 00102 SetMethod( "GET" ); 00103 AddResponseHeader( "Accept", "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1"); 00104 AddResponseHeader( "Accept-Language", "en-us,en;q=0.5"); 00105 AddResponseHeader( "Accept-Encoding", "gzip,deflate"); 00106 AddResponseHeader( "Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"); 00107 AddResponseHeader( "User-agent", MyUseragent() ); 00108 00109 if (GetUrlPort() != 80 && GetUrlPort() != 443) 00110 AddResponseHeader( "Host", GetUrlHost() + ":" + Utility::l2string(GetUrlPort()) ); 00111 else 00112 AddResponseHeader( "Host", GetUrlHost() ); 00113 SendRequest(); 00114 }
HttpGetSocket& HttpGetSocket::operator= | ( | const HttpGetSocket & | ) | [inline, protected] |