1 #include "ace/OS_NS_stdio.h"
2 #include "ace/OS_NS_string.h"
3 #include "URL_Visitor.h"
9 HTTP_URL::url_addr () const
11 return this->url_addr_
;
14 HTTP_URL::HTTP_URL (const ACE_URL_Addr
&url_addr
,
16 : url_addr_ (url_addr
),
17 containing_page_ (cp
== 0 ? this : cp
)
19 ACE_DEBUG ((LM_DEBUG
, "HTTP_URL %s\n", url_addr
.addr_to_string ()));
23 HTTP_URL::send_request ()
26 ACE_OS::strlen (this->url_addr ().get_path_name ())
27 + ACE_OS::strlen (this->url_addr ().get_host_name ())
30 + 16; // Protocol filler...
33 ACE_NEW_RETURN (command
,
37 // Ensure that the <command> memory is deallocated.
38 std::unique_ptr
<char[]> cmd_ptr (command
);
40 ACE_OS::sprintf (cmd_ptr
.get (),
41 "GET /%s HTTP/1.1\r\n",
42 ACE_TEXT_ALWAYS_CHAR (this->url_addr ().get_path_name ()));
44 // Send the GET command to the connected server.
45 if (this->stream ().send_n (cmd_ptr
.get (),
46 ACE_OS::strlen (cmd_ptr
.get ()),
47 const_cast<ACE_Time_Value
*>
48 (OPTIONS::instance ()->timeout ())) > 0)
50 ACE_OS::sprintf (cmd_ptr
.get (),
52 this->url_addr ().get_host_name ());
54 // IMP: The length of teh command has to be sent!
56 this->stream ().send_n (cmd_ptr
.get (),
57 ACE_OS::strlen (cmd_ptr
.get ()),
58 const_cast<ACE_Time_Value
*>
59 (OPTIONS::instance ()->timeout ()));
60 this->stream ().svc_handler ()->idle (0);
71 HTTP_URL::accept (URL_Visitor
*visitor
)
73 // This is part of the visitor pattern.
74 return visitor
->visit (*this);