2 * @file HTTP_SessionBase.h
4 * @author Martin Corino <mcorino@remedy.nl>
7 #ifndef ACE_HTTP_SESSION_BASE_H
8 #define ACE_HTTP_SESSION_BASE_H
10 #include /**/ "ace/pre.h"
12 #include "ace/SString.h"
13 #include "ace/Countdown_Time.h"
14 #include "ace/Synch_Options.h"
15 #include "ace/INet/INet_Export.h"
16 #include "ace/INet/HTTP_Request.h"
17 #include "ace/INet/HTTP_Response.h"
18 #include "ace/INet/HTTP_IOStream.h"
20 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
27 * @class ACE_HTTP_SessionBase
29 * @brief Abstract base class for HTTP(S) sessions.
32 class ACE_INET_Export SessionBase
35 SessionBase (u_short port
,
36 bool keep_alive
= false);
38 SessionBase (u_short port
,
39 const ACE_Time_Value
& timeout
,
40 bool keep_alive
= false,
41 const ACE_Time_Value
* alive_timeout
= 0);
43 virtual ~SessionBase ();
45 void set_keep_alive (bool f
);
47 bool keep_alive () const;
49 virtual bool is_connected () const = 0;
51 void set_host (const ACE_CString
& host
,
54 void set_host (const ACE_CString
& host
);
56 void set_port (u_short port
);
58 void set_proxy_target (const ACE_CString
& host
, u_short port
);
60 const ACE_CString
& get_host () const;
62 u_short
get_port () const;
64 bool is_proxy_connection () const;
66 const ACE_CString
& get_proxy_target_host () const;
68 u_short
get_proxy_target_port () const;
70 bool connect (bool use_reactor
= false);
72 std::ostream
& send_request (Request
& request
);
74 std::ostream
& request_stream ();
76 std::ostream
& request_stream (ACE::IOS::StreamInterceptor
& interceptor
);
78 std::istream
& receive_response (Response
& response
);
80 std::istream
& response_stream ();
82 std::istream
& response_stream (ACE::IOS::StreamInterceptor
& interceptor
);
87 bool reconnect_needed ();
89 void close_streams ();
91 virtual bool connect_i (const ACE_Synch_Options
& sync_opt
) = 0;
93 virtual void close_i () = 0;
95 virtual std::iostream
& sock_stream () = 0;
99 DEFAULT_TIMEOUT
= 30, // sec
100 DEFAULT_KEEP_ALIVE_TIMEOUT
= 8 // sec
105 bool proxy_connection_
;
106 ACE_CString proxy_target_host_
;
107 u_short proxy_target_port_
;
111 OStream
* out_stream_
;
112 ACE_Time_Value http_timeout_
;
113 ACE_Time_Value keep_alive_timeout_
;
114 ACE_Time_Value reconnect_timer_
;
115 ACE_Countdown_Time reconnect_countdown_
;
117 bool needs_reconnect_
;
118 bool cannot_reconnect_
;
119 bool expects_response_body_
;
124 ACE_END_VERSIONED_NAMESPACE_DECL
126 #if defined (__ACE_INLINE__)
127 #include "ace/INet/HTTP_SessionBase.inl"
130 #include /**/ "ace/post.h"
131 #endif /* ACE_HTTP_SESSION_BASE_H */