1 #ifndef CONNECT___NCBI_HTTP_SESSION__HPP
2 #define CONNECT___NCBI_HTTP_SESSION__HPP
174 string GetHttpHeader(
void)
const;
179 static const char* GetHeaderName(EHeaderName name);
189 : m_Host(std::move(host)),
m_Port(port) {}
190 CHttpProxy(
string host,
unsigned short port,
string user,
string password)
191 : m_Host(std::move(host)),
m_Port(port), m_User(std::move(user)), m_Password(std::move(password)) {}
193 bool IsEmpty(
void)
const {
return m_Host.empty(); }
194 const string&
GetHost(
void)
const {
return m_Host; }
196 const string&
GetUser(
void)
const {
return m_User; }
231 CHttpParam& SetCredentials(shared_ptr<CTlsCertCredentials> credentials);
232 shared_ptr<CTlsCertCredentials>
GetCredentials(
void)
const {
return m_Credentials; }
414 bool IsEmpty(
void)
const;
431 void SetContentType(EContentType content_type);
462 string GetContentTypeStr(
void)
const;
465 static string CreateBoundary(
void);
506 bool CanGetContentStream(
void)
const;
539 const string&
GetCert(
void)
const {
return m_Cert; }
540 const string&
GetPKey(
void)
const {
return m_PKey; }
586 CHttpRequest& SetTimeout(
unsigned int sec,
unsigned int usec = 0);
618 template<
class TCallback>
644 template<
class TCallback>
654 void x_InitConnection(
bool use_form_data);
655 void x_InitConnection2(shared_ptr<iostream> stream);
657 bool x_CanSendData(
void)
const;
661 void x_AddCookieHeader(
const CUrl& url,
bool initial);
663 void x_AdjustHeaders(
bool use_form_data);
676 unsigned int failure_count);
784 void SetCredentials(shared_ptr<CTlsCertCredentials> cred);
785 shared_ptr<CTlsCertCredentials>
GetCredentials(
void)
const {
return m_Credentials; }
803 string x_GetCookies(
const CUrl& url)
const;
853 virtual const char* GetErrCodeString(
void)
const override;
Helper hook-up class that installs default logging/registry/locking (but only if they have not yet be...
CHttpSession and CHttpRequest parameters.
Per-request proxy settings.
CHttpSessionException –.
HTTP session class, holding common data for multiple requests.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
CTimeout – Timeout interval.
Wrapper class for NCBI_CRED.
std::ofstream out("events_result.xml")
main entry point for tests
unsigned int THTTP_Flags
Bitwise OR of EHTTP_Flag.
EHTTP_HeaderParse
The extended version HTTP_CreateConnectorEx() is able to track the HTTP response chain and also chang...
shared_ptr< iostream > m_Stream
virtual string GetFileName(void) const
Get optional filename to be shown in Content-Disposition header.
void SetRetries(THttpRetries retries)
Set number of retries.
vector< SFormData > TValues
shared_ptr< CTlsCertCredentials > GetCredentials(void) const
THttpRetries GetRetries(void) const
EHeaderName
Some standard HTTP headers.
EProtocol GetProtocol(void) const
Get protocol version.
const THeaders & Get() const
const CHttpProxy & GetProxy(void) const
CHttpHeaders & operator=(const CHttpHeaders &)
const CTimeout & GetTimeout(void) const
Get current timeout.
const string & GetPKey(void) const
shared_ptr< CTlsCertCredentials > GetCredentials(void) const
map< string, TProviders > TProviderEntries
CRef< CAdjustUrlCallback_Base > m_AdjustUrl
THttpRetries GetRetries(void) const
Get number of retries.
const CTimeout & GetDeadline() const
const CTimeout & GetDeadline() const
Get current deadline for Execute().
const string & GetHost(void) const
CHeaderNameConverter(CTempString name)
ESwitch GetRetryProcessing() const
CRef< CHttpHeaders > m_Headers
int GetStatusCode(void) const
Get response status code.
CTlsCertCredentials(const CTlsCertCredentials &)
CRef< CHttpSession_Base > m_Session
map< string, TValues > TEntries
unsigned short GetPort(void) const
CRef< CHttpSession_Base > m_Session
const CHttpHeaders & Headers(void) const
Get incoming HTTP headers.
void x_InitConnection(bool use_form_data)
const CTimeout & GetTimeout(void) const
CHttpFormData(const CHttpFormData &)
const string & GetPassword(void) const
EContentType GetContentType(void) const
Get current content type.
CHeaderNameConverter(const string &name)
CHeaderNameConverter(const char *name)
CHttpParam & SetRetryProcessing(ESwitch on_off)
virtual string GetContentType(void) const
Get content type.
CHttpHeaders(const CHttpHeaders &)
void SetProxy(const CHttpProxy &proxy)
Set proxy.
virtual ~CHttpSession_Base(void)
virtual bool AdjustUrl(CUrl &url)
EContentType
Supported content types for POST requests.
shared_ptr< iostream > m_Stream
CNullable< unsigned short, SGetHttpDefaultRetries > THttpRetries
Nullable retries for CHttpRequest.
CTempString GetName(void)
ESwitch m_RetryProcessing
vector< CRef< CFormDataProvider_Base > > TProviders
CHttpProxy(string host, unsigned short port, string user, string password)
ESwitch GetRetryProcessing() const
Return whether Execute() will wait for actual response.
void SetHttpFlags(THTTP_Flags flags)
Set flags passed to CConn_HttpStream.
CRef< CHttpHeaders > m_Headers
const CHttpHeaders & GetHeaders(void) const
CHttpHeaders & Headers(void)
Get HTTP headers to be sent.
CRef< CHttpFormData > m_FormData
virtual ~CFormDataProvider_Base(void)
shared_ptr< CTlsCertCredentials > m_Credentials
void SetAdjustUrlCallback(TCallback callback)
Set callback to adjust URL after resolving service location.
const string & GetCert(void) const
CHttpProxy(string host, unsigned short port)
CHeaderNameConverter(CHttpHeaders::EHeaderName name)
const string & GetStatusText(void) const
Get response status text.
CHttpResponse g_HttpPost(const CUrl &url, CTempString data, const CHttpParam ¶m=CHttpParam())
Shortcut for POST request.
CHttpHeaders(void)
Create empty headers list.
const CHttpProxy & GetProxy(void) const
virtual bool x_Downgrade(CHttpResponse &resp, EProtocol &protocol) const =0
const CHttpCookies & Cookies(void) const
Get all stored cookies.
NCBI_EXCEPTION_DEFAULT(CHttpSessionException, CException)
TProviderEntries m_Providers
virtual ~CHttpHeaders(void)
virtual ~CHttpResponse(void)
ESwitch m_RetryProcessing
void SetProtocol(EProtocol protocol)
EContentType m_ContentType
THTTP_Flags GetHttpFlags(void) const
Get flags passed to CConn_HttpStream.
virtual ~CAdjustUrlCallback_Base(void)
CHttpResponse g_HttpPut(const CUrl &url, CTempString data, const CHttpParam ¶m=CHttpParam())
Shortcut for PUT request.
const CHttpProxy & GetProxy(void) const
unsigned short operator()(void) const
virtual void WriteData(CNcbiOstream &out) const =0
Write user data to the stream.
shared_ptr< CTlsCertCredentials > m_Credentials
CHttpCookies & Cookies(void)
Get all stored cookies, non-const.
CTlsCertCredentials & operator=(const CTlsCertCredentials &)
shared_ptr< CTlsCertCredentials > m_Credentials
virtual void x_StartRequest(EProtocol protocol, CHttpRequest &req, bool use_form_data)=0
virtual bool AdjustUrl(CUrl &url)=0
bool x_Downgrade(CHttpResponse &, EProtocol &) const override
ERequestMethod
Supported request methods, proxy for EReqMethod.
void SetProxy(const CHttpProxy &proxy)
CRef< CHttpResponse > m_Response
CHttpResponse g_HttpGet(const CUrl &url, const CHttpParam ¶m)
Shortcut for GET request.
virtual ~CHttpFormData(void)
CHttpParam & SetDeadline(const CTimeout &deadline)
const CUrl & GetLocation(void) const
Get actual resource location.
CHttpParam & SetProxy(const CHttpProxy &proxy)
const string & GetUser(void) const
CRef< CHttpHeaders > m_Headers
vector< string > THeaderValues
List of header values (may be required for headers with multiple values like Cookie).
CHttpFormData & operator=(const CHttpFormData &)
void x_StartRequest(EProtocol protocol, CHttpRequest &req, bool use_form_data) override
EProtocol
HTTP protocol version.
CAdjustUrlCallback(TCallback &callback)
friend class CHttpRequest
map< string, THeaderValues, PNocase > THeaders
Map of header name-values, case-insensitive.
@ eFormUrlEncoded
'application/x-www-form-urlencoded', default
@ eBadStream
Wrong stream used to read content or error.
@ eBadFormData
Bad form data (e.g. unreadable file).
@ eBadContentType
Content-type conflicts with the data.
@ eBadFormDataName
Empty or bad name in form data.
@ eBadRequest
Error initializing or sending a request.
@ eConnFailed
Failed to open connection.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
unsigned short m_Port
TCP port to listen on.
@ eDefault
Default timeout (to be interpreted by the client code)
enum ENcbiSwitch ESwitch
Aux.
#define NCBI_XCONNECT_EXPORT
const TYPE & Get(const CNamedParameterList *param)
string Execute(const string &cmmd, const vector< string > &args, const string &data=kEmptyStr)
const GenericPointer< typename T::ValueType > T2 value
void Merge(wxMenu &menu_1, const wxMenu &menu_2)
merges all items form menu_2 into menu_1, preserving the structure if possible