1 #include "ace/INet/HTTP_URL.h"
3 #if !defined (__ACE_INLINE__)
4 #include "ace/INet/HTTP_URL.inl"
7 #include "ace/INet/String_IOStream.h"
8 #include "ace/INet/HTTP_ClientRequestHandler.h"
10 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
16 const char* URL::PROTOCOL
= "http";
18 const ACE_CString
& URL::protocol ()
20 static const ACE_CString
protocol_ (PROTOCOL
);
25 : ACE::INet::URL_INetAuthBase (HTTP_PORT
),
26 proxy_port_ (HTTP_PROXY_PORT
)
30 URL::URL (const ACE_CString
& url_string
)
31 : ACE::INet::URL_INetAuthBase (HTTP_PORT
),
32 proxy_port_ (HTTP_PROXY_PORT
)
34 this->parse (url_string
);
37 URL::URL (const URL
& url
)
38 : ACE::INet::URL_INetAuthBase (0)
43 URL::URL (u_short port
)
44 : ACE::INet::URL_INetAuthBase (port
),
45 proxy_port_ (HTTP_PROXY_PORT
)
53 URL
& URL::operator =(const URL
& url
)
55 this->set_user_info (url
.get_user_info ());
56 this->set_host (url
.get_host ());
57 this->set_port (url
.get_port ());
58 this->set_path (url
.get_path ());
59 this->set_query (url
.get_query ());
60 this->set_fragment (url
.get_fragment ());
61 this->set_proxy (url
.get_proxy_host (), url
.get_proxy_port ());
65 ACE_CString
URL::get_request_uri () const
67 ACE::IOS::CString_OStream sos
;
68 if (!this->proxy_host_
.empty ())
70 sos
<< this->get_scheme ().c_str () << "://"
71 << ACE::INet::URL_INetBase::get_host ().c_str ();
72 if (ACE::INet::URL_INetBase::get_port () != HTTP_PORT
)
74 sos
<< ':' << ACE::INet::URL_INetBase::get_port ();
77 // if path is empty we're requesting the root
78 sos
<< (this->get_path ().empty () ?
80 this->get_path ().c_str ());
81 if (!this->get_query ().empty ())
82 sos
<< '?' << this->get_query ().c_str ();
83 if (!this->get_fragment ().empty ())
84 sos
<< '#' << this->get_fragment ().c_str ();
88 ACE_CString
URL::to_string () const
90 ACE::IOS::CString_OStream sos
;
91 sos
<< this->get_scheme () << "://"
92 << this->get_authority ().c_str ()
93 << this->get_path ().c_str ();
94 if (!this->get_query ().empty ())
95 sos
<< '?' << this->get_query ().c_str ();
96 if (!this->get_fragment ().empty ())
97 sos
<< '#' << this->get_fragment ().c_str ();
101 ACE::INet::ClientRequestHandler
* URL::create_default_request_handler () const
103 ACE::INet::ClientRequestHandler
* prh
= 0;
104 ACE_NEW_NORETURN (prh
, ClientRequestHandler ());
108 const URL::Factory
& URL::factory_
= *URL::TURLFactorySingleton::instance ();
110 URL::Factory::Factory ()
112 ACE::INet::URL_Base::register_factory (this);
115 URL::Factory::~Factory ()
118 const ACE_CString
& URL::Factory::protocol ()
120 return URL::protocol ();
123 ACE::INet::URL_Base
* URL::Factory::create_from_string (const ACE_CString
& url_string
)
126 ACE_NEW_NORETURN (purl
, URL (url_string
));
132 ACE_END_VERSIONED_NAMESPACE_DECL