Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / HTTP_Client.cpp
blobd353a5a58208cb29d08c866437538992a51e72c7
1 #include "tao/HTTP_Client.h"
3 #if (TAO_HAS_HTTP_PARSER == 1)
5 #include "tao/HTTP_Handler.h"
6 #include "ace/OS_NS_string.h"
7 #include "ace/Truncate.h"
8 #include "tao/debug.h"
10 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
12 TAO_HTTP_Client::TAO_HTTP_Client ()
13 : filename_ (nullptr)
17 TAO_HTTP_Client::~TAO_HTTP_Client ()
19 this->close ();
22 int
23 TAO_HTTP_Client::open (const ACE_TCHAR *filename,
24 const ACE_TCHAR *hostname,
25 u_short port)
27 this->filename_ = ACE_OS::strdup (filename);
28 this->inet_addr_.set (port, hostname);
29 return 0;
32 int
33 TAO_HTTP_Client::read (ACE_Message_Block *mb)
35 // Create a HTTP_Client Reader
36 TAO_HTTP_Reader HTTP_reader (mb, this->filename_);
37 TAO_HTTP_Handler *brp = &HTTP_reader;
39 // Connect to the server
40 if (connector_.connect (brp, this->inet_addr_) == -1)
42 TAOLIB_ERROR_RETURN ((LM_ERROR, "TAO (%P|%t) - HTTP_Client::read, Connector error\n"), -1);
45 return ACE_Utils::truncate_cast<int> (HTTP_reader.byte_count ());
48 int
49 TAO_HTTP_Client::close ()
51 if (this->filename_)
53 ACE_OS::free ((void *) this->filename_);
54 this->filename_ = nullptr;
56 return 0;
59 TAO_END_VERSIONED_NAMESPACE_DECL
61 #endif /* TAO_HAS_HTTP_PARSER == 1 */