// $Id: $ #include "ace/Auto_Ptr.h" #include "URL_Visitor.h" #include "Options.h" #include "HTTP_URL.h" const ACE_URL_Addr & HTTP_URL::url_addr (void) const { return this->url_addr_; } HTTP_URL::HTTP_URL (const ACE_URL_Addr &url_addr, HTTP_URL *cp) : url_addr_ (url_addr), containing_page_ (cp == 0 ? this : cp) { } int HTTP_URL::send_request (void) { // Since this is HTTP 1.0 we'll need to establish a connection // before we can send the request. if (this->stream ().open (this->url_addr ()) == -1) return -1; int commandsize = ACE_OS::strlen (this->url_addr ().get_path_name ()) + 1 // NUL byte + 16; // Protocol filler... char *command; ACE_NEW_RETURN (command, char[commandsize], -1); // Ensure that the memory is deallocated. ACE_Auto_Basic_Array_Ptr cmd_ptr (command); ACE_OS::sprintf (cmd_ptr.get (), "GET /%s HTTP/1.0\n\n", this->url_addr ().get_path_name ()); // Send the GET command to the connected server. return this->stream ().send_n (cmd_ptr.get (), commandsize - 1); } int HTTP_URL::accept (URL_Visitor *visitor) { // This is part of the visitor pattern. return visitor->visit (*this); }