NCBI C++ ToolKit
Public Member Functions | Protected Attributes | Static Private Member Functions | List of all members
CConn_HttpStream Class Reference

Search Toolkit Book for CConn_HttpStream

This stream exchanges data with an HTTP server located at the URL: http[s]://host[:port]/path[?args]. More...

#include <connect/ncbi_conn_stream.hpp>

+ Inheritance diagram for CConn_HttpStream:
+ Collaboration diagram for CConn_HttpStream:

Public Member Functions

 CConn_HttpStream (const string &host, const string &path, const string &args=kEmptyStr, const string &user_header=kEmptyStr, unsigned short port=0, THTTP_Flags flags=fHTTP_AutoReconnect, const STimeout *timeout=kDefaultTimeout, size_t buf_size=kConn_DefaultBufSize)
 
 CConn_HttpStream (const string &url, THTTP_Flags flags=fHTTP_AutoReconnect, const STimeout *timeout=kDefaultTimeout, size_t buf_size=kConn_DefaultBufSize)
 
 CConn_HttpStream (const string &url, EReqMethod method, const string &user_header=kEmptyStr, THTTP_Flags flags=fHTTP_AutoReconnect, const STimeout *timeout=kDefaultTimeout, size_t buf_size=kConn_DefaultBufSize)
 
 CConn_HttpStream (const string &url, const SConnNetInfo *net_info, const string &user_header=kEmptyStr, FHTTP_ParseHeader parse_header=0, void *user_data=0, FHTTP_Adjust adjust=0, FHTTP_Cleanup cleanup=0, THTTP_Flags flags=fHTTP_AutoReconnect, const STimeout *timeout=kDefaultTimeout, size_t buf_size=kConn_DefaultBufSize)
 
 CConn_HttpStream (const SConnNetInfo *net_info=0, const string &user_header=kEmptyStr, FHTTP_ParseHeader parse_header=0, void *user_data=0, FHTTP_Adjust adjust=0, FHTTP_Cleanup cleanup=0, THTTP_Flags flags=fHTTP_AutoReconnect, const STimeout *timeout=kDefaultTimeout, size_t buf_size=kConn_DefaultBufSize)
 
virtual ~CConn_HttpStream ()
 
void SetURL (const string &url)
 Set new URL to hit next. More...
 
- Public Member Functions inherited from CConn_HttpStream_Base
int GetStatusCode (void) const
 Get the last seen HTTP status code, if available. More...
 
const CTempString GetStatusText (void) const
 Get the last seen HTTP status text, if available. More...
 
const stringGetHTTPHeader (void) const
 Get the last seen HTTP header text, if available. More...
 
- Public Member Functions inherited from CConn_IOStream
 CConn_IOStream (CONN conn, bool close=false, const STimeout *timeout=kDefaultTimeout, size_t buf_size=kConn_DefaultBufSize, TConn_Flags flags=0, CT_CHAR_TYPE *ptr=0, size_t size=0)
 Create a stream based on CONN, which is to be closed upon stream dtor but only if "close" parameter is passed as "true". More...
 
virtual ~CConn_IOStream ()
 
string GetType (void) const
 
string GetDescription (void) const
 
EIO_Status SetTimeout (EIO_Event direction, const STimeout *timeout) const
 Set connection timeout for "direction". More...
 
const STimeoutGetTimeout (EIO_Event direction) const
 
EIO_Status Status (EIO_Event direction=eIO_Close) const
 
EIO_Status Fetch (const STimeout *timeout=kDefaultTimeout)
 Flush the stream and fetch the response (w/o extracting any user data) More...
 
virtual EIO_Status Pushback (const CT_CHAR_TYPE *data, streamsize size)
 Push the specified data "data" of size "size" back into the underlying connection CONN (making it look like received yet unread data). More...
 
SOCK GetSOCK (void)
 Get underlying SOCK, if available (e.g. after Fetch()) More...
 
CSocketGetSocket (void)
 Get CSocket, if available (else empty). More...
 
virtual EIO_Status Close (void)
 Close CONNection, free all internal buffers and underlying structures, and render the stream unusable for further I/O. More...
 
EIO_Status SetCanceledCallback (const ICanceled *canceled)
 Cancellation support. More...
 
CONN GetCONN (void) const
 
EIO_Status Wait (EIO_Event event, const STimeout *timeout=&kZeroTimeout)
 Equivalent to CONN_Wait(GetCONN(), event, timeout) More...
 

Protected Attributes

void * m_UserData
 
FHTTP_Adjust m_UserAdjust
 
FHTTP_Cleanup m_UserCleanup
 
FHTTP_ParseHeader m_UserParseHeader
 
string m_URL
 
- Protected Attributes inherited from CConn_HttpStream_Base
SHTTP_StatusData m_StatusData
 
- Protected Attributes inherited from CConn_IOStream
CConn_Streambufm_CSb
 

Static Private Member Functions

static int sx_Adjust (SConnNetInfo *net_info, void *data, unsigned int count)
 
static void sx_Cleanup (void *data)
 
static EHTTP_HeaderParse sx_ParseHeader (const char *header, void *data, int code)
 

Additional Inherited Members

- Public Types inherited from CConn_IOStream
enum  { fConn_Untie = fCONN_Untie , fConn_DelayOpen = 2 , fConn_ReadUnbuffered = 4 , fConn_WriteUnbuffered = 8 }
 The values below must be compatible with TCONN_Flags. More...
 
typedef unsigned int TConn_Flags
 bitwise OR of EConn_Flag More...
 
typedef pair< CONNECTOR, EIO_StatusTConnPair
 
- Public Attributes inherited from CConn_IOStream
enum CConn_IOStream:: { ... }  EConn_Flag
 The values below must be compatible with TCONN_Flags. More...
 
- Static Public Attributes inherited from CConn_IOStream
static const STimeout kZeroTimeout = { 0, 0 }
 Polling timeout with the 0.0 time in it. More...
 
- Protected Member Functions inherited from CConn_HttpStream_Base
 CConn_HttpStream_Base (const TConnector &connector, const STimeout *timeout, size_t buf_size, TConn_Flags flags=0)
 
- Protected Member Functions inherited from CConn_IOStream
 CConn_IOStream (const TConnector &connector, const STimeout *timeout=kDefaultTimeout, size_t buf_size=kConn_DefaultBufSize, TConn_Flags flags=0, CT_CHAR_TYPE *ptr=0, size_t size=0)
 Create a stream based on CONNECTOR – only for internal use in derived classes. More...
 
EIO_Status x_Pushback (const CT_CHAR_TYPE *data, streamsize size, bool push=false)
 
void x_Destroy (void)
 
- Protected Member Functions inherited from CConnIniter
 CConnIniter (void)
 

Detailed Description

This stream exchanges data with an HTTP server located at the URL: http[s]://host[:port]/path[?args].

Note that "path" must include the leading slash, "args" can be empty, in which case the '?' does not get appended to the path.

"User_header" (if not empty) should be a sequence of lines in the form 'HTTP-tag: Tag value', with each line separated by a CR LF sequence, and the last line optionally terminated with a CR LF sequence. For example: "Content-Encoding: gzip\r\nContent-Type: application/octet-stream" It is included in the HTTP-header of each transaction.

More elaborate specification(s) of the server can be made via the SConnNetInfo structure, which otherwise will be created with the use of a standard registry section to obtain default values from (details: <connect/ncbi_connutil.h>). To make sure the actual user header is empty, remember to reset it with ConnNetInfo_SetUserHeader(net_info, 0).

THTTP_Flags and other details: <connect/ncbi_http_connector.h>.

Provided "timeout" is set at the connection level, and if different from kDefaultTimeout, it overrides a value supplied by the HTTP connector (the latter value is kept at SConnNetInfo::timeout).

See also
CConn_IOStream, HTTP_CreateConnector, ConnNetInfo_Create

Definition at line 716 of file ncbi_conn_stream.hpp.


The documentation for this class was generated from the following files:
Modified on Sun Feb 25 03:00:09 2024 by modify_doxy.py rev. 669887