Logo
~Sockets~
~Examples~
~Contact~


HttpGetSocket Class Reference
[HTTP Sockets]

Get http page. More...

#include <HttpGetSocket.h>

Inheritance diagram for HttpGetSocket:
Collaboration diagram for HttpGetSocket:

List of all members.


Public Member Functions

 HttpGetSocket (ISocketHandler &)
 HttpGetSocket (ISocketHandler &, const std::string &url, const std::string &to_file="")
 HttpGetSocket (ISocketHandler &, const std::string &host, port_t port, const std::string &url, const std::string &to_file="")
 ~HttpGetSocket ()
void OnConnect ()
 Called when a connection has completed.

Protected Member Functions

HttpGetSocketoperator= (const HttpGetSocket &)
 HttpGetSocket (const HttpGetSocket &s)

Detailed Description

Get http page.

Definition at line 43 of file HttpGetSocket.h.


Constructor & Destructor Documentation

HttpGetSocket::HttpGetSocket ( ISocketHandler h  ) 

Definition at line 47 of file HttpGetSocket.cpp.

00047                                               : HttpClientSocket(h)
00048 {
00049 }

HttpGetSocket::HttpGetSocket ( ISocketHandler h,
const std::string &  url,
const std::string &  to_file = "" 
)

Definition at line 52 of file HttpGetSocket.cpp.

References StreamSocket::Connecting(), HttpClientSocket::GetUrlHost(), HttpClientSocket::GetUrlPort(), Socket::Handler(), LOG_LEVEL_FATAL, ISocketHandler::LogError(), TcpSocket::Open(), Socket::SetCloseAndDelete(), and HttpClientSocket::SetFilename().

00052                                                                                                : HttpClientSocket(h, url_in)
00053 {
00054         if (to_file.size())
00055         {
00056                 SetFilename(to_file);
00057         }
00058         if (!Open(GetUrlHost(),GetUrlPort()))
00059         {
00060                 if (!Connecting())
00061                 {
00062                         Handler().LogError(this, "HttpGetSocket", -1, "connect() failed miserably", LOG_LEVEL_FATAL);
00063                         SetCloseAndDelete();
00064                 }
00065         }
00066 }

HttpGetSocket::HttpGetSocket ( ISocketHandler h,
const std::string &  host,
port_t  port,
const std::string &  url,
const std::string &  to_file = "" 
)

Definition at line 69 of file HttpGetSocket.cpp.

References StreamSocket::Connecting(), Socket::Handler(), LOG_LEVEL_FATAL, ISocketHandler::LogError(), TcpSocket::Open(), Socket::SetCloseAndDelete(), HttpClientSocket::SetFilename(), and HTTPSocket::SetUrl().

00069                                                                                                                               : HttpClientSocket(h, host, port, url)
00070 {
00071         SetUrl(url);
00072         if (to_file.size())
00073         {
00074                 SetFilename(to_file);
00075         }
00076         if (!Open(host, port))
00077         {
00078                 if (!Connecting())
00079                 {
00080                         Handler().LogError(this, "HttpGetSocket", -1, "connect() failed miserably", LOG_LEVEL_FATAL);
00081                         SetCloseAndDelete();
00082                 }
00083         }
00084 }

HttpGetSocket::~HttpGetSocket (  ) 

Definition at line 87 of file HttpGetSocket.cpp.

00088 {
00089 }

HttpGetSocket::HttpGetSocket ( const HttpGetSocket s  )  [inline, protected]

Definition at line 55 of file HttpGetSocket.h.

00055 : HttpClientSocket(s) {}


Member Function Documentation

void HttpGetSocket::OnConnect (  )  [virtual]

Called when a connection has completed.

Reimplemented from Socket.

Definition at line 92 of file HttpGetSocket.cpp.

References HTTPSocket::AddResponseHeader(), HttpClientSocket::GetUrlHost(), HttpClientSocket::GetUrlPort(), Utility::l2string(), HTTPSocket::MyUseragent(), HTTPSocket::SendRequest(), and HTTPSocket::SetMethod().

00093 {
00094         SetMethod( "GET" );
00095         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");
00096         AddResponseHeader( "Accept-Language", "en-us,en;q=0.5");
00097         AddResponseHeader( "Accept-Encoding", "gzip,deflate");
00098         AddResponseHeader( "Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
00099         AddResponseHeader( "User-agent", MyUseragent() );
00100 
00101         if (GetUrlPort() != 80 && GetUrlPort() != 443)
00102                 AddResponseHeader( "Host", GetUrlHost() + ":" + Utility::l2string(GetUrlPort()) );
00103         else
00104                 AddResponseHeader( "Host", GetUrlHost() );
00105         SendRequest();
00106 }

HttpGetSocket& HttpGetSocket::operator= ( const HttpGetSocket  )  [inline, protected]

Definition at line 54 of file HttpGetSocket.h.

00054 { return *this; }


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4