NCBI C++ ToolKit
|
Classes | |
class | CConn_IOStream |
Base class, inherited from "std::iostream", does both input and output, using the specified CONNECTOR. More... | |
class | CConn_IOStream::TConnector |
Helper class to build streams on top of CONNECTOR (internal use only). More... | |
class | CConn_IOStreamSetTimeout |
class | CConn_IOStreamSetReadTimeout |
class | CConn_IOStreamSetWriteTimeout |
class | CConn_SocketStream |
This stream exchanges data in a TCP channel, using the SOCK socket API. More... | |
struct | SHTTP_StatusData |
Helper class to fetch HTTP status code and text. More... | |
class | CConn_HttpStream_Base |
Helper base class for HTTP-like streams. More... | |
class | CConn_HttpStream |
This stream exchanges data with an HTTP server located at the URL: http[s]://host[:port]/path[?args]. More... | |
class | CConn_ServiceStream |
This stream exchanges data with a named service, in a constraint that the service is implemented as one of the specified server "types" (details: <connect/ncbi_server_info.h>). More... | |
class | CConn_MemoryStream |
In-memory stream (a la strstream or stringstream) More... | |
class | CConn_PipeStream |
CConn_PipeStream for command piping. More... | |
class | CConn_NamedPipeStream |
CConn_NamedPipeStream for inter-process communication. More... | |
class | CConn_FtpStream |
CConn_FtpStream is an elaborate FTP client, can be used for data downloading and/or uploading to and from an FTP server. More... | |
class | CConn_FTPDownloadStream |
CConn_FtpStream specialization (ctor) for download. More... | |
class | CConn_FTPUploadStream |
CConn_FtpStream specialization (ctor) for upload. More... | |
Typedefs | |
typedef unsigned int | CConn_IOStream::TConn_Flags |
bitwise OR of EConn_Flag More... | |
typedef pair< CONNECTOR, EIO_Status > | CConn_IOStream::TConnPair |
Enumerations | |
enum | { CConn_IOStream::fConn_Untie = fCONN_Untie , CConn_IOStream::fConn_DelayOpen = 2 , CConn_IOStream::fConn_ReadUnbuffered = 4 , CConn_IOStream::fConn_WriteUnbuffered = 8 } |
The values below must be compatible with TCONN_Flags. More... | |
Friends | |
CConn_IOStreamSetReadTimeout | CConn_IOStreamSetReadTimeout::SetReadTimeout (const STimeout *) |
CConn_IOStreamSetWriteTimeout | CConn_IOStreamSetWriteTimeout::SetWriteTimeout (const STimeout *) |
typedef unsigned int CConn_IOStream::TConn_Flags |
bitwise OR of EConn_Flag
Definition at line 147 of file ncbi_conn_stream.hpp.
typedef pair<CONNECTOR, EIO_Status> CConn_IOStream::TConnPair |
Definition at line 181 of file ncbi_conn_stream.hpp.
anonymous enum |
The values below must be compatible with TCONN_Flags.
Enumerator | |
---|---|
fConn_Untie | do not flush before reading |
fConn_DelayOpen | do not force CONN open in ctor |
fConn_ReadUnbuffered | read buffer NOT to be alloc'd |
fConn_WriteUnbuffered | write buffer NOT 2.b. alloc'd |
Definition at line 141 of file ncbi_conn_stream.hpp.
CConn_FTPDownloadStream::CConn_FTPDownloadStream | ( | const SConnNetInfo & | net_info, |
TFTP_Flags | flag = 0 , |
||
const SFTP_Callback * | cmcb = 0 , |
||
Uint8 | offset = 0 , |
||
const STimeout * | timeout = kDefaultTimeout , |
||
size_t | buf_size = kConn_DefaultBufSize |
||
) |
offset | file offset to begin download at |
Definition at line 1407 of file ncbi_conn_stream.cpp.
References offset, SConnNetInfo::path, and CConn_FTPDownloadStream::x_InitDownload().
CConn_FTPDownloadStream::CConn_FTPDownloadStream | ( | const string & | host, |
const string & | file = kEmptyStr , |
||
const string & | user = "ftp" , |
||
const string & | pass = "-none@" , |
||
const string & | path = kEmptyStr , |
||
unsigned short | port = 0 , |
||
TFTP_Flags | flag = 0 , |
||
const SFTP_Callback * | cmcb = 0 , |
||
Uint8 | offset = 0 , |
||
const STimeout * | timeout = kDefaultTimeout , |
||
size_t | buf_size = kConn_DefaultBufSize |
||
) |
port | 0 means default (21 for FTP) |
offset | file offset to begin download at |
Definition at line 1388 of file ncbi_conn_stream.cpp.
References file, offset, and CConn_FTPDownloadStream::x_InitDownload().
CConn_FtpStream::CConn_FtpStream | ( | const SConnNetInfo & | net_info, |
TFTP_Flags | flag = 0 , |
||
const SFTP_Callback * | cmcb = 0 , |
||
const STimeout * | timeout = kDefaultTimeout , |
||
size_t | buf_size = kConn_DefaultBufSize |
||
) |
Definition at line 1306 of file ncbi_conn_stream.cpp.
CConn_FtpStream::CConn_FtpStream | ( | const string & | host, |
const string & | user, | ||
const string & | pass, | ||
const string & | path = kEmptyStr , |
||
unsigned short | port = 0 , |
||
TFTP_Flags | flag = 0 , |
||
const SFTP_Callback * | cmcb = 0 , |
||
const STimeout * | timeout = kDefaultTimeout , |
||
size_t | buf_size = kConn_DefaultBufSize |
||
) |
Definition at line 1278 of file ncbi_conn_stream.cpp.
CConn_FTPUploadStream::CConn_FTPUploadStream | ( | const SConnNetInfo & | net_info, |
TFTP_Flags | flag = 0 , |
||
Uint8 | offset = 0 , |
||
const STimeout * | timeout = kDefaultTimeout |
||
) |
offset | file offset to start upload at |
Definition at line 1458 of file ncbi_conn_stream.cpp.
References offset, SConnNetInfo::path, and CConn_FTPUploadStream::x_InitUpload().
CConn_FTPUploadStream::CConn_FTPUploadStream | ( | const string & | host, |
const string & | user, | ||
const string & | pass, | ||
const string & | file = kEmptyStr , |
||
const string & | path = kEmptyStr , |
||
unsigned short | port = 0 , |
||
TFTP_Flags | flag = 0 , |
||
Uint8 | offset = 0 , |
||
const STimeout * | timeout = kDefaultTimeout |
||
) |
port | 0 means default (21 for FTP) |
offset | file offset to start upload at |
Definition at line 1441 of file ncbi_conn_stream.cpp.
References file, offset, and CConn_FTPUploadStream::x_InitUpload().
CConn_HttpStream::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 |
||
) |
Definition at line 741 of file ncbi_conn_stream.cpp.
CConn_HttpStream::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 |
||
) |
port | default(e.g. 80=HTTP/443=HTTPS) |
Definition at line 619 of file ncbi_conn_stream.cpp.
CConn_HttpStream::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 |
||
) |
Definition at line 706 of file ncbi_conn_stream.cpp.
CConn_HttpStream::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 |
||
) |
Definition at line 677 of file ncbi_conn_stream.cpp.
CConn_HttpStream::CConn_HttpStream | ( | const string & | url, |
THTTP_Flags | flags = fHTTP_AutoReconnect , |
||
const STimeout * | timeout = kDefaultTimeout , |
||
size_t | buf_size = kConn_DefaultBufSize |
||
) |
Definition at line 650 of file ncbi_conn_stream.cpp.
|
inlineprotected |
Definition at line 672 of file ncbi_conn_stream.hpp.
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".
conn | A C object of type CONN (ncbi_connection.h) on top of which the stream is being constructed. May not be NULL. |
close | True if to close CONN automatically (otherwise CONN remains open) |
timeout | Default I/O timeout (including to open the stream) |
buf_size | Default size of underlying stream buffer's I/O arena (per direction) |
flags | Specifies whether to tie input and output (a tied stream flushes all pending output prior to doing any input) and what to buffer |
ptr | Specifies data which will be read from the stream prior to extracting from the actual connection (must not be modified while I/O not done) |
size | The size of the area pointed to by the "ptr" argument |
Definition at line 73 of file ncbi_conn_stream.cpp.
References eIO_Close, eIO_Success, init(), CConn_IOStream::m_CSb, and CConn_IOStream::x_CSb.
|
private |
|
protected |
Create a stream based on CONNECTOR – only for internal use in derived classes.
The passed CONNECTOR always gets closed by stream dtor.
connector | CONNECTOR coupled with an error code (if any) |
timeout | Default I/O timeout (including to open the stream) |
buf_size | Default size of underlying stream buffer's I/O arena (per direction) |
flags | Specifies whether to tie input and output (a tied stream flushes all pending output prior to doing any input), and what to buffer |
ptr | Specifies data which will be read from the stream prior to extracting from the actual connection (must not be modified while I/O not done) |
size | The size of the area pointed to by the "ptr" argument |
Definition at line 59 of file ncbi_conn_stream.cpp.
References eIO_Close, eIO_Success, init(), CConn_IOStream::m_CSb, and CConn_IOStream::x_CSb.
|
inlineprotected |
Definition at line 400 of file ncbi_conn_stream.hpp.
Definition at line 385 of file ncbi_conn_stream.hpp.
|
inlineprotected |
Definition at line 429 of file ncbi_conn_stream.hpp.
CConn_MemoryStream::CConn_MemoryStream | ( | BUF | buf, |
EOwnership | owner = eTakeOwnership , |
||
size_t | buf_size = kConn_DefaultBufSize |
||
) |
Build a stream on top of an NCBI buffer (which in turn could have been built over a memory area of a specified size).
BUF's ownership is assumed by the stream as specified in "owner".
Definition at line 1061 of file ncbi_conn_stream.cpp.
CConn_MemoryStream::CConn_MemoryStream | ( | const void * | ptr, |
size_t | size, | ||
EOwnership | owner, | ||
size_t | buf_size = kConn_DefaultBufSize |
||
) |
Build a stream on top of an existing data area of a specified size.
The contents of the area are what will be read first from the stream. Writing to the stream will _not_ modify the contents of the area. When read from the stream, the written data will appear following the initial data block. Ownership of the area pointed to by "ptr" is controlled by the "owner" parameter, and if the ownership is passed to the stream the area will be deleted by "delete[] (char*)" from the stream destructor. That is, if there are any requirements to be considered for deleting the area (like deleting an object or an array of objects), then the ownership must not be passed to the stream. Note that the area pointed to by "ptr" should not be changed while it is still holding the data yet to be read from the stream.
owner | no default for safety |
Definition at line 1077 of file ncbi_conn_stream.cpp.
CConn_MemoryStream::CConn_MemoryStream | ( | size_t | buf_size = kConn_DefaultBufSize | ) |
Definition at line 1052 of file ncbi_conn_stream.cpp.
CConn_NamedPipeStream::CConn_NamedPipeStream | ( | const string & | pipename, |
size_t | pipesize = 0 , |
||
const STimeout * | timeout = kDefaultTimeout , |
||
size_t | buf_size = kConn_DefaultBufSize |
||
) |
Definition at line 1202 of file ncbi_conn_stream.cpp.
CConn_PipeStream::CConn_PipeStream | ( | const string & | cmd, |
const vector< string > & | args, | ||
CPipe::TCreateFlags | flags = 0 , |
||
size_t | pipe_size = 0 , |
||
const STimeout * | timeout = kDefaultTimeout , |
||
size_t | buf_size = kConn_DefaultBufSize |
||
) |
Definition at line 1166 of file ncbi_conn_stream.cpp.
CConn_ServiceStream::CConn_ServiceStream | ( | const string & | service, |
const string & | user_header, | ||
TSERV_Type | types = fSERV_Any , |
||
const SSERVICE_Extra * | extra = 0 , |
||
const STimeout * | timeout = kDefaultTimeout , |
||
size_t | buf_size = kConn_DefaultBufSize |
||
) |
Definition at line 942 of file ncbi_conn_stream.cpp.
CConn_ServiceStream::CConn_ServiceStream | ( | const string & | service, |
TSERV_Type | types = fSERV_Any , |
||
const SConnNetInfo * | net_info = 0 , |
||
const SSERVICE_Extra * | extra = 0 , |
||
const STimeout * | timeout = kDefaultTimeout , |
||
size_t | buf_size = kConn_DefaultBufSize |
||
) |
Definition at line 912 of file ncbi_conn_stream.cpp.
CConn_SocketStream::CConn_SocketStream | ( | const SConnNetInfo & | net_info, |
const void * | data = 0 , |
||
size_t | size = 0 , |
||
TSOCK_Flags | flgs = fSOCK_LogDefault , |
||
const STimeout * | timeout = kDefaultTimeout , |
||
size_t | buf_size = kConn_DefaultBufSize , |
||
TConn_Flags | flags = 0 |
||
) |
Create a tunneled socket stream connection.
The following fields of SConnNetInfo are used (other ignored):
scheme – must be http or unspecified, checked host:port – target server http_proxy_host:http_proxy_port – HTTP proxy server to tunnel thru http_proxy_user:http_proxy_pass – credentials for the proxy, if needed http_proxy_leak – ignore bad proxy and connect direct timeout – timeout to connect to HTTP proxy firewall – if true then look at proxy_server proxy_server – use as "host" if non-empty and FW debug_printout – how to log socket data by default http_push_auth – whether to push credentials at once
net_info | Connection point and proxy tunnel location |
data | Pointer to block of data to send once connection is ready |
size | Size of the data block to send (or 0 if to send nothing) |
flgs | Socket flags (see <connect/ncbi_socket.h>) |
timeout | Default I/O timeout |
buf_size | Default buffer size |
flags | Specifies whether to tie input and output (a tied stream flushes all pending output prior to doing any input), and what to buffer |
Definition at line 474 of file ncbi_conn_stream.cpp.
CConn_SocketStream::CConn_SocketStream | ( | const string & | host, |
unsigned short | port, | ||
unsigned short | max_try, | ||
const STimeout * | timeout = kDefaultTimeout , |
||
size_t | buf_size = kConn_DefaultBufSize , |
||
TConn_Flags | flags = 0 |
||
) |
Create a direct connection with host:port.
host | Host to connect to |
port | ... and port number |
max_try | Number of attempts |
timeout | Default I/O timeout |
buf_size | Default buffer size |
flags | Specifies whether to tie input and output (a tied stream flushes all pending output prior to doing any input), and what to buffer |
host | host to connect to |
port | ... and port number |
max_try | number of attempts |
Definition at line 255 of file ncbi_conn_stream.cpp.
CConn_SocketStream::CConn_SocketStream | ( | const string & | host, |
unsigned short | port = 0 , |
||
const void * | data = 0 , |
||
size_t | size = 0 , |
||
TSOCK_Flags | flgs = fSOCK_LogDefault , |
||
unsigned short | max_try = DEF_CONN_MAX_TRY , |
||
const STimeout * | timeout = kDefaultTimeout , |
||
size_t | buf_size = kConn_DefaultBufSize , |
||
TConn_Flags | flags = 0 |
||
) |
Create a direct connection with "host:port" and send an initial "data" block of the specified "size" first; the remaining communication can proceed as usual.
host | Host to connect to |
port | ... and port number (however, see a note below) |
data | Pointer to block of data to send once connection is ready |
size | Size of the data block to send (or 0 if to send nothing) |
flgs | Socket flgs (see <connect/ncbi_socket.h>) |
max_try | Number of attempts |
timeout | Default I/O timeout |
buf_size | Default buffer size |
flags | Specifies whether to tie input and output (a tied stream flushes all pending output prior to doing any input), and what to buffer |
host | host[:port] to connect |
port | ... and port number |
data | initial data block |
size | size of the data block |
flgs | see ncbi_socket.h |
max_try | number of attempts |
Definition at line 307 of file ncbi_conn_stream.cpp.
CConn_SocketStream::CConn_SocketStream | ( | CSocket & | socket, |
const STimeout * | timeout = kDefaultTimeout , |
||
size_t | buf_size = kConn_DefaultBufSize , |
||
TConn_Flags | flags = 0 |
||
) |
This variant uses an existing CSocket to build a stream up on it.
NOTE: this always revokes all ownership of the "socket"'s internals (effectively leaving the CSocket empty); CIO_Exception(eInvalidArg) is thrown if the internal SOCK is not owned by the passed CSocket. More details: <ncbi_socket_connector.h>SOCK_CreateConnectorOnTop().
socket | Socket to build the stream up on |
timeout | Default I/O timeout |
buf_size | Default buffer size |
flags | Specifies whether to tie input and output (a tied stream flushes all pending output prior to doing any input), and what to buffer |
socket | socket, underlying SOCK always grabbed |
Definition at line 358 of file ncbi_conn_stream.cpp.
CConn_SocketStream::CConn_SocketStream | ( | SOCK | sock, |
EOwnership | if_to_own, | ||
const STimeout * | timeout = kDefaultTimeout , |
||
size_t | buf_size = kConn_DefaultBufSize , |
||
TConn_Flags | flags = 0 |
||
) |
This variant uses an existing socket "sock" to build a stream upon it.
The caller may retain the ownership of "sock" by passing "if_to_own" as "eNoOwnership" to the stream constructor – in that case, the socket "sock" will not be closed / destroyed upon stream destruction, and can further be used (including proper closing when no longer needed). Otherwise, "sock" becomes invalid once the stream is closed/destroyed. NOTE: To maintain data integrity and consistency, "sock" should not be used elsewhere while it is also being in use by the stream. More details: <ncbi_socket_connector.h>SOCK_CreateConnectorOnTop().
sock | Socket to build the stream on |
if_to_own | Whether the sock object is owned (managed) by the stream at dtor |
timeout | Default I/O timeout |
buf_size | Default buffer size |
flags | Specifies whether to tie input and output (a tied stream flushes all pending output prior to doing any input), and what to buffer |
sock | socket |
if_to_own | whether stream to own "sock" param |
Definition at line 324 of file ncbi_conn_stream.cpp.
|
inline |
Definition at line 646 of file ncbi_conn_stream.hpp.
References CTempString::clear(), SHTTP_StatusData::m_Code, SHTTP_StatusData::m_Header, and SHTTP_StatusData::m_Text.
Referenced by SHTTP_StatusData::Parse(), and CConn_HttpStream::sx_Adjust().
|
virtual |
Close CONNection, free all internal buffers and underlying structures, and render the stream unusable for further I/O.
Reimplemented in CConn_PipeStream.
Definition at line 183 of file ncbi_conn_stream.cpp.
References _ASSERT, CConn_Streambuf::Close(), eCopyTimeoutsFromSOCK, eIO_Success, eNoOwnership, GET_CONN, CConn_IOStream::m_Canceled, CConn_IOStream::m_CSb, CConn_IOStream::m_Socket, NcbiBadbit, CSocket::Reset(), and CConstRef< C, Locker >::Reset().
Referenced by CConn_PipeStream::Close(), CDownloadJob::x_Download(), and CDownloadJob::x_DownloadAndExtract().
|
virtual |
Close CONNection, free all internal buffers and underlying structures, and render the stream unusable for further I/O.
Reimplemented from CConn_IOStream.
Definition at line 1189 of file ncbi_conn_stream.cpp.
References CPipe::Close(), CConn_IOStream::Close(), eIO_Write, CConn_PipeStream::m_ExitCode, CConn_PipeStream::m_Pipe, and CConn_IOStream::Status().
|
virtual |
Abort any command in progress, read and discard all input data, and clear stream error state when successful (eIO_Success returns)
Definition at line 1352 of file ncbi_conn_stream.cpp.
References _VERIFY, conn, CONN_GetTimeout(), CONN_Read(), CONN_SetTimeout(), CONN_Write(), eIO_Read, eIO_ReadPersist, eIO_ReadPlain, eIO_ReadWrite, eIO_Success, eIO_Write, eIO_WritePersist, CConn_IOStream::GetCONN(), kInfiniteTimeout, and n.
EIO_Status CConn_IOStream::Fetch | ( | const STimeout * | timeout = kDefaultTimeout | ) |
Flush the stream and fetch the response (w/o extracting any user data)
Definition at line 139 of file ncbi_conn_stream.cpp.
References conn, eIO_NotSupported, CConn_Streambuf::Fetch(), GET_CONN, CConn_IOStream::m_CSb, and NcbiBadbit.
Referenced by CCDDClient::JustAsk(), and CID2Client::JustAsk().
BUF CConn_MemoryStream::GetBUF | ( | void | ) |
Get the underlying BUF handle (it still remains managed by the stream)
Definition at line 1145 of file ncbi_conn_stream.cpp.
References CConn_IOStream::GetCONN(), SConnectorTag::handle, and SMetaConnector::list.
CONN CConn_IOStream::GetCONN | ( | void | ) | const |
Definition at line 96 of file ncbi_conn_stream.cpp.
References GET_CONN, and CConn_IOStream::m_CSb.
Referenced by CConnTest::CheckFWConnections(), CReaderServiceConnector::Connect(), CConnTest::ConnStatus(), CConn_FtpStream::Drain(), CAsnConverter< TCpp, TC >::FromC(), CConn_MemoryStream::GetBUF(), CReaderServiceConnector::GetConnDescription(), CAsnConverter< TCpp, TC >::ToC(), CId1Reader::x_ConnectAtSlot(), CId2Reader::x_ConnectAtSlot(), CDownloadJob::x_Download(), CDownloadJob::x_DownloadAndExtract(), and CId2FetchApp::x_InitConnection().
string CConn_IOStream::GetDescription | ( | void | ) | const |
Definition at line 110 of file ncbi_conn_stream.cpp.
References conn, CONN_Description(), GET_CONN, kEmptyStr, CConn_IOStream::m_CSb, and text().
Referenced by CConnTest::ConnStatus().
|
inline |
A valid exit code is only made available after an explicit Close()
Definition at line 957 of file ncbi_conn_stream.hpp.
References CConn_PipeStream::m_ExitCode.
Get the last seen HTTP header text, if available.
Definition at line 667 of file ncbi_conn_stream.hpp.
References SHTTP_StatusData::m_Header, and CConn_HttpStream_Base::m_StatusData.
Referenced by CUrlUtils::GetLastModified(), CUrlUtils::IfModifiedSince(), and CHttpRequest::sx_ParseHeader().
|
inline |
Return an underlying CPipe; it's valid for as long as the stream exists.
Definition at line 962 of file ncbi_conn_stream.hpp.
References CConn_PipeStream::m_Pipe.
Referenced by edirect::Execute(), and CWindowMaskerJob::x_CreateProjectItems().
SOCK CConn_IOStream::GetSOCK | ( | void | ) |
Get underlying SOCK, if available (e.g. after Fetch())
Definition at line 164 of file ncbi_conn_stream.cpp.
References _ASSERT, conn, CONN_GetSOCK(), eIO_Success, GET_CONN, and CConn_IOStream::m_CSb.
Referenced by CConn_IOStream::GetSocket().
|
inline |
Get CSocket, if available (else empty).
The returned CSocket doesn't own the underlying SOCK, and is valid for as long as the stream exists.
Definition at line 452 of file ncbi_conn_stream.hpp.
References eCopyTimeoutsFromSOCK, eNoOwnership, CConn_IOStream::GetSOCK(), CConn_IOStream::m_Socket, and CSocket::Reset().
Referenced by CConnTest::CheckFWConnections().
|
inline |
Get the last seen HTTP status code, if available.
Definition at line 661 of file ncbi_conn_stream.hpp.
References SHTTP_StatusData::m_Code, and CConn_HttpStream_Base::m_StatusData.
Referenced by CNcbiApplogApp::Cmd_Health(), CUrlUtils::GetLastModified(), CUrlUtils::IfModifiedSince(), CNcbiApplogApp::ReadCgiResponse(), CHttpRequest::sx_ParseHeader(), CEutilsClient::x_FetchOnce(), CEutilsClient::x_GetOnce(), x_IsUrlAccessible(), CEutilsClient::x_LinkOnce(), CEutilsClient::x_LinkOnceT(), CEutilsClient::x_LinkOutOnce(), CEutilsClient::x_SearchOnce(), and CEutilsClient::x_SummaryOnce().
|
inline |
Get the last seen HTTP status text, if available.
Definition at line 664 of file ncbi_conn_stream.hpp.
References CConn_HttpStream_Base::m_StatusData, and SHTTP_StatusData::m_Text.
Referenced by CHttpRequest::sx_ParseHeader().
Definition at line 126 of file ncbi_conn_stream.cpp.
References conn, CONN_GetTimeout(), GET_CONN, kDefaultTimeout, and CConn_IOStream::m_CSb.
Referenced by CRPCClient< TRequest, TReply >::GetTimeout().
Definition at line 382 of file ncbi_conn_stream.hpp.
string CConn_IOStream::GetType | ( | void | ) | const |
Definition at line 102 of file ncbi_conn_stream.cpp.
References conn, CONN_GetType(), GET_CONN, kEmptyStr, CConn_IOStream::m_CSb, and type.
Referenced by CConnTest::ConnStatus().
CConn_IOStream* NcbiOpenURL | ( | const string & | url, |
size_t | buf_size = kConn_DefaultBufSize |
||
) |
Given a URL, open the data source and make it available for _reading_.
See <connect/ncbi_connutil.h> for supported schemes.
If "url" looks like an identifier (no scheme provided), then it will be opened as a named NCBI service (using CConn_ServiceStream); if the "url" looks like a string in the form "host:port", a socket to that host and port will be connected (using CConn_SocketStream); otherwise, a stream will be created according to the URL scheme (recognized are: "ftp://", "http://", "https://", and "file://").
Definition at line 1518 of file ncbi_conn_stream.cpp.
References _ASSERT, ConnNetInfo_CreateInternal(), ConnNetInfo_Log(), ConnNetInfo_ParseURL(), ConnNetInfo_SetUserHeader(), CORE_GetLOG(), CORE_LOCK_READ, CORE_UNLOCK, eLOG_Note, NStr::eNocase, eReqMethod_Any, eReqMethod_Connect, ERR_POST_X, Error(), eURL_File, eURL_Ftp, eURL_Http, eURL_Https, fHTTP_AutoReconnect, NStr::Find(), free(), fSERV_Any, fSOCK_LogDefault, AutoPtr< X, Del >::get(), kDefaultTimeout, kEmptyStr, kInfiniteTimeout, len, make_c_unique(), NCBI_HasSpaces(), SERV_ServiceName(), NStr::StartsWith(), CSocketAPI::StringToHostPort(), and x_IsIdentifier().
|
inline |
Stream manipulator "os << SetWriteTimeout(timeout)".
Definition at line 443 of file ncbi_conn_stream.hpp.
References eIO_Success, eIO_Write, CConn_IOStreamSetWriteTimeout::GetTimeout(), NcbiBadbit, and CConn_IOStream::SetTimeout().
|
private |
|
private |
|
inline |
Stream manipulator "is >> SetReadTimeout(timeout)".
Definition at line 414 of file ncbi_conn_stream.hpp.
References eIO_Read, eIO_Success, CConn_IOStreamSetReadTimeout::GetTimeout(), NcbiBadbit, and CConn_IOStream::SetTimeout().
EHTTP_HeaderParse SHTTP_StatusData::Parse | ( | const char * | header | ) |
Definition at line 501 of file ncbi_conn_stream.cpp.
References CTempString::assign(), SHTTP_StatusData::Clear(), eHTTP_HeaderError, eHTTP_HeaderSuccess, HTTP_EOL, isspace(), SHTTP_StatusData::m_Code, SHTTP_StatusData::m_Header, SHTTP_StatusData::m_Text, n, and str().
Referenced by CConn_HttpStream::sx_ParseHeader(), and CConn_ServiceStream::sx_ParseHeader().
|
inlinevirtual |
Push the specified data "data" of size "size" back into the underlying connection CONN (making it look like received yet unread data).
If there is any non-empty pending input sequence (internal read buffer) it will be attempted to return to CONN first. Note that it can include any initial read area ("ptr"), which could have been specified in the ctor yet still unread, so potentially unwanted data copying may result.
Reimplemented in CConn_MemoryStream.
Definition at line 296 of file ncbi_conn_stream.hpp.
References data, ncbi::grid::netcache::search::fields::size, and CConn_IOStream::x_Pushback().
|
inlinevirtual |
Push the specified data "data" of size "size" back into the underlying connection CONN (making it look like received yet unread data).
If there is any non-empty pending input sequence (internal read buffer) it will be attempted to return to CONN first. Note that it can include any initial read area ("ptr"), which could have been specified in the ctor yet still unread, so potentially unwanted data copying may result.
Reimplemented from CConn_IOStream.
Definition at line 901 of file ncbi_conn_stream.hpp.
References data, ncbi::grid::netcache::search::fields::size, and CConn_IOStream::x_Pushback().
EIO_Status CConn_IOStream::SetCanceledCallback | ( | const ICanceled * | canceled | ) |
Cancellation support.
Definition at line 204 of file ncbi_conn_stream.cpp.
References conn, CONN_SetCallback(), SCONN_Callback::data, eCONN_OnFlush, eCONN_OnOpen, eCONN_OnRead, eCONN_OnWrite, eIO_NotSupported, eIO_Success, SCONN_Callback::func, GET_CONN, CConn_IOStream::m_Canceled, CConn_IOStream::m_CB, CConn_IOStream::m_CSb, CConstRef< C, Locker >::NotNull(), and CConn_IOStream::sx_IsCanceled().
Referenced by CConnTest::CheckFWConnections(), CConnTest::DispatcherOkay(), CConnTest::HttpOkay(), CConnTest::ServiceOkay(), CConnTest::StatefulOkay(), and CConnTest::x_GetFirewallConfiguration().
|
inline |
Definition at line 407 of file ncbi_conn_stream.hpp.
EIO_Status CConn_IOStream::SetTimeout | ( | EIO_Event | direction, |
const STimeout * | timeout | ||
) | const |
Set connection timeout for "direction".
Can | accept a pointer to a finite timeout, or either of the special values: kInfiniteTimeout, kDefaultTimeout |
Definition at line 118 of file ncbi_conn_stream.cpp.
References conn, CONN_SetTimeout(), eIO_NotSupported, GET_CONN, and CConn_IOStream::m_CSb.
Referenced by CConnTest::CheckFWConnections(), operator<<(), operator>>(), and CRPCClient< TRequest, TReply >::SetTimeout().
Set new URL to hit next.
Definition at line 774 of file ncbi_conn_stream.hpp.
References CConn_HttpStream::m_URL.
|
inline |
Definition at line 436 of file ncbi_conn_stream.hpp.
|
private |
|
inline |
Definition at line 640 of file ncbi_conn_stream.hpp.
EIO_Status CConn_IOStream::Status | ( | EIO_Event | direction = eIO_Close | ) | const |
Definition at line 133 of file ncbi_conn_stream.cpp.
References eIO_NotSupported, CConn_IOStream::m_CSb, and CConn_Streambuf::Status().
Referenced by CConnTest::CheckFWConnections(), CConn_PipeStream::Close(), CConnTest::ConnStatus(), CConn_FTPDownloadStream::x_InitDownload(), and CConn_FTPUploadStream::x_InitUpload().
|
staticprivate |
Definition at line 804 of file ncbi_conn_stream.cpp.
References _ASSERT, SHTTP_StatusData::Clear(), ConnNetInfo_ParseURL(), data, failure, CConn_IOStream::m_CSb, CConn_HttpStream_Base::m_StatusData, CConn_HttpStream::m_URL, CConn_HttpStream::m_UserAdjust, CConn_HttpStream::m_UserData, NCBI_CATCH_ALL, and THROW1_TRACE.
|
staticprivate |
Definition at line 1001 of file ncbi_conn_stream.cpp.
References SSERVICE_Extra::adjust, SSERVICE_Extra::data, data, failure, CConn_ServiceStream::m_Extra, NCBI_CATCH_ALL, and THROW1_TRACE.
|
staticprivate |
Definition at line 837 of file ncbi_conn_stream.cpp.
References data, CConn_HttpStream::m_UserCleanup, CConn_HttpStream::m_UserData, and NCBI_CATCH_ALL.
|
staticprivate |
Definition at line 1042 of file ncbi_conn_stream.cpp.
References SSERVICE_Extra::cleanup, SSERVICE_Extra::data, data, CConn_ServiceStream::m_Extra, and NCBI_CATCH_ALL.
|
staticprivate |
Definition at line 1337 of file ncbi_conn_stream.cpp.
References cmd, SFTP_Callback::data, data, eIO_Unknown, failure, SFTP_Callback::func, CConn_FtpStream::m_Cmcb, NCBI_CATCH_ALL, and THROW1_TRACE.
|
staticprivate |
Definition at line 1016 of file ncbi_conn_stream.cpp.
References SSERVICE_Extra::data, data, failure, SSERVICE_Extra::get_next_info, CConn_ServiceStream::m_Extra, NCBI_CATCH_ALL, and THROW1_TRACE.
|
staticprivate |
Definition at line 234 of file ncbi_conn_stream.cpp.
References _ASSERT, conn, SCONN_Callback::data, data, eCONN_OnFlush, eCONN_OnOpen, eCONN_OnRead, eCONN_OnWrite, eIO_Interrupt, eIO_ReadWrite, eIO_Success, SCONN_Callback::func, int, CConn_IOStream::m_Canceled, CConn_IOStream::m_CB, n, and CConstRef< C, Locker >::NotNull().
Referenced by CConn_IOStream::SetCanceledCallback().
|
staticprivate |
Definition at line 782 of file ncbi_conn_stream.cpp.
References _ASSERT, data, eHTTP_HeaderError, eHTTP_HeaderSuccess, failure, SHTTP_StatusData::m_Code, CConn_IOStream::m_CSb, CConn_HttpStream_Base::m_StatusData, CConn_HttpStream::m_UserData, CConn_HttpStream::m_UserParseHeader, NCBI_CATCH_ALL, SHTTP_StatusData::Parse(), and THROW1_TRACE.
|
staticprivate |
Definition at line 979 of file ncbi_conn_stream.cpp.
References _ASSERT, SSERVICE_Extra::data, data, eHTTP_HeaderError, eHTTP_HeaderSuccess, failure, SHTTP_StatusData::m_Code, CConn_IOStream::m_CSb, CConn_ServiceStream::m_Extra, CConn_HttpStream_Base::m_StatusData, NCBI_CATCH_ALL, SHTTP_StatusData::Parse(), SSERVICE_Extra::parse_header, and THROW1_TRACE.
|
staticprivate |
Definition at line 1030 of file ncbi_conn_stream.cpp.
References SSERVICE_Extra::data, data, failure, CConn_ServiceStream::m_Extra, NCBI_CATCH_ALL, SSERVICE_Extra::reset, and THROW1_TRACE.
|
inline |
connector | A C object of type CONNECTOR (ncbi_connector.h) on top of which a stream will be constructed. NULL CONNECTOR indicates an error (if none is passed in the second argument, eIO_Unknown results). |
status | I/O status to use in the underlying streambuf (e.g. when CONNECTOR is NULL), and if non-eIO_Success will also cause a non-NULL CONNECTOR (if any passed in the first argument) to be destroyed. |
Definition at line 197 of file ncbi_conn_stream.hpp.
void CConn_MemoryStream::ToString | ( | string * | str | ) |
The CConnMemoryStream::To* methods allow to obtain unread portion of the stream into a single container (as a string or a vector) so that all data is kept in sequential memory locations.
Note that the operation is considered an extraction, so it effectively empties the stream, and both methods actually move the data from the stream to the respective containers. fill in the data, NULL is not accepted
Definition at line 1098 of file ncbi_conn_stream.cpp.
References _ASSERT, NCBI_THROW, ncbi::grid::netcache::search::fields::size, and str().
Referenced by CFlatFileGenerator::GetSeqFeatText(), CProjectStorage::GetString(), RequestToString(), and CTMS_DisplayTrack_Client::x_HttpFetch().
void CConn_MemoryStream::ToVector | ( | vector< char > * | vec | ) |
fill in the data, NULL is not accepted
Definition at line 1121 of file ncbi_conn_stream.cpp.
References _ASSERT, NCBI_THROW, and ncbi::grid::netcache::search::fields::size.
Referenced by CProjectStorage::GetVector().
EIO_Status CConn_IOStream::Wait | ( | EIO_Event | event, |
const STimeout * | timeout = &kZeroTimeout |
||
) |
Equivalent to CONN_Wait(GetCONN(), event, timeout)
event | eIO_Read or eIO_Write |
timeout | Time to wait for the event (poll if zero time specified, and return immediately) |
Definition at line 176 of file ncbi_conn_stream.cpp.
References conn, CONN_Wait(), GET_CONN, and CConn_IOStream::m_CSb.
|
protected |
Definition at line 197 of file ncbi_conn_stream.cpp.
References CConn_IOStream::m_CSb, and CConn_IOStream::x_CSb.
Referenced by CConn_FtpStream::~CConn_FtpStream(), CConn_HttpStream::~CConn_HttpStream(), CConn_IOStream::~CConn_IOStream(), CConn_MemoryStream::~CConn_MemoryStream(), CConn_PipeStream::~CConn_PipeStream(), and CConn_ServiceStream::~CConn_ServiceStream().
Definition at line 1421 of file ncbi_conn_stream.cpp.
References eIO_Success, eIO_Write, NStr::EndsWith(), file, NcbiBadbit, offset, CConn_IOStream::Status(), and NStr::UInt8ToString().
Referenced by CConn_FTPDownloadStream::CConn_FTPDownloadStream().
Definition at line 1470 of file ncbi_conn_stream.cpp.
References eIO_Success, eIO_Write, file, NcbiBadbit, NcbiFlush, offset, CConn_IOStream::Status(), and NStr::UInt8ToString().
Referenced by CConn_FTPUploadStream::CConn_FTPUploadStream().
|
protected |
Definition at line 152 of file ncbi_conn_stream.cpp.
References data, eIO_NotSupported, eIO_Success, CConn_IOStream::m_CSb, NcbiBadbit, CConn_Streambuf::Pushback(), and ncbi::grid::netcache::search::fields::size.
Referenced by CConn_IOStream::Pushback(), and CConn_MemoryStream::Pushback().
|
virtual |
Definition at line 1330 of file ncbi_conn_stream.cpp.
References CConn_IOStream::x_Destroy().
|
virtual |
Definition at line 775 of file ncbi_conn_stream.cpp.
References CConn_IOStream::x_Destroy().
|
virtual |
Definition at line 87 of file ncbi_conn_stream.cpp.
References CConn_IOStream::x_Destroy().
|
virtual |
Definition at line 1090 of file ncbi_conn_stream.cpp.
References CT_CHAR_TYPE, CConn_MemoryStream::m_Ptr, and CConn_IOStream::x_Destroy().
|
virtual |
Definition at line 1181 of file ncbi_conn_stream.cpp.
References CConn_PipeStream::m_Pipe, and CConn_IOStream::x_Destroy().
|
virtual |
Definition at line 972 of file ncbi_conn_stream.cpp.
References CConn_IOStream::x_Destroy().
enum { ... } CConn_IOStream::EConn_Flag |
The values below must be compatible with TCONN_Flags.
const size_t kConn_DefaultBufSize = 16384 |
I/O buffer size per direction.
Definition at line 109 of file ncbi_conn_stream.hpp.
Polling timeout with the 0.0 time in it.
Definition at line 138 of file ncbi_conn_stream.hpp.
|
private |
Definition at line 370 of file ncbi_conn_stream.hpp.
Referenced by CConn_IOStream::Close(), CConn_IOStream::SetCanceledCallback(), and CConn_IOStream::sx_IsCanceled().
|
private |
Definition at line 369 of file ncbi_conn_stream.hpp.
Referenced by CConn_IOStream::SetCanceledCallback(), and CConn_IOStream::sx_IsCanceled().
|
protected |
Definition at line 1043 of file ncbi_conn_stream.hpp.
Referenced by CConn_FtpStream::sx_FtpCallback().
int SHTTP_StatusData::m_Code |
Definition at line 636 of file ncbi_conn_stream.hpp.
Referenced by SHTTP_StatusData::Clear(), CConn_HttpStream_Base::GetStatusCode(), SHTTP_StatusData::Parse(), CConn_HttpStream::sx_ParseHeader(), and CConn_ServiceStream::sx_ParseHeader().
|
protected |
Definition at line 361 of file ncbi_conn_stream.hpp.
Referenced by CConn_IOStream::CConn_IOStream(), CConn_IOStream::Close(), CConn_IOStream::Fetch(), CConn_IOStream::GetCONN(), CConn_IOStream::GetDescription(), CConn_IOStream::GetSOCK(), CConn_IOStream::GetTimeout(), CConn_IOStream::GetType(), CConn_IOStream::SetCanceledCallback(), CConn_IOStream::SetTimeout(), CConn_IOStream::Status(), CConn_HttpStream::sx_Adjust(), CConn_HttpStream::sx_ParseHeader(), CConn_ServiceStream::sx_ParseHeader(), CConn_IOStream::Wait(), CConn_IOStream::x_Destroy(), and CConn_IOStream::x_Pushback().
|
protected |
Process exit code.
Definition at line 966 of file ncbi_conn_stream.hpp.
Referenced by CConn_PipeStream::Close(), and CConn_PipeStream::GetExitCode().
|
protected |
Definition at line 843 of file ncbi_conn_stream.hpp.
Referenced by CConn_ServiceStream::sx_Adjust(), CConn_ServiceStream::sx_Cleanup(), CConn_ServiceStream::sx_GetNextInfo(), CConn_ServiceStream::sx_ParseHeader(), and CConn_ServiceStream::sx_Reset().
string SHTTP_StatusData::m_Header |
Definition at line 638 of file ncbi_conn_stream.hpp.
Referenced by SHTTP_StatusData::Clear(), CConn_HttpStream_Base::GetHTTPHeader(), and SHTTP_StatusData::Parse().
|
protected |
Underlying pipe.
Definition at line 965 of file ncbi_conn_stream.hpp.
Referenced by CConn_PipeStream::Close(), CConn_PipeStream::GetPipe(), and CConn_PipeStream::~CConn_PipeStream().
|
protected |
pointer to read memory area (if owned)
Definition at line 919 of file ncbi_conn_stream.hpp.
Referenced by CConn_MemoryStream::~CConn_MemoryStream().
|
private |
Definition at line 366 of file ncbi_conn_stream.hpp.
Referenced by CConn_IOStream::Close(), and CConn_IOStream::GetSocket().
|
protected |
CTempString SHTTP_StatusData::m_Text |
Definition at line 637 of file ncbi_conn_stream.hpp.
Referenced by SHTTP_StatusData::Clear(), CConn_HttpStream_Base::GetStatusText(), and SHTTP_StatusData::Parse().
Definition at line 390 of file ncbi_conn_stream.hpp.
Referenced by CConn_IOStreamSetWriteTimeout::GetTimeout().
|
protected |
Definition at line 784 of file ncbi_conn_stream.hpp.
Referenced by CConn_HttpStream::SetURL(), and CConn_HttpStream::sx_Adjust().
|
protected |
Definition at line 779 of file ncbi_conn_stream.hpp.
Referenced by CConn_HttpStream::sx_Adjust().
|
protected |
Definition at line 780 of file ncbi_conn_stream.hpp.
Referenced by CConn_HttpStream::sx_Cleanup().
|
protected |
Definition at line 778 of file ncbi_conn_stream.hpp.
Referenced by CConn_HttpStream::sx_Adjust(), CConn_HttpStream::sx_Cleanup(), and CConn_HttpStream::sx_ParseHeader().
|
protected |
Definition at line 781 of file ncbi_conn_stream.hpp.
Referenced by CConn_HttpStream::sx_ParseHeader().
|
private |
Definition at line 365 of file ncbi_conn_stream.hpp.
Referenced by CConn_IOStream::CConn_IOStream(), and CConn_IOStream::x_Destroy().
|
friend |
Definition at line 407 of file ncbi_conn_stream.hpp.
|
friend |
Definition at line 436 of file ncbi_conn_stream.hpp.