ost::URLStream(3)
π ost::URLStream(3) β Library Functions Manual π
okay bestie, gather round, because today we're learning about ost::URLStream, and it's genuinely such a slay little class. it lives in section 3 of the manual (that's the library functions girlies), and it is, no cap, a URL processing version of TCPStream. that's the whole vibe. periodt. β¨
β¨ NAME β¨
ost::URLStream β a URL processing version of TCPStream. π
πΈ SYNOPSIS πΈ
#include <url.h>
Inherits ost::TCPStream. yes she's got lineage, she's a nepo baby and we love that for her π«Ά
π Public Types π
enum Errorβ return error for url fetch. values:errSuccess = 0,errUnreachable,errMissing,errDenied,errInvalid,errForbidden,errUnauthorized,errRelocated,errFailure,errTimeout,errInterfaceenum Authenticationβ type of authentication. values:authAnonymous = 0,authBasicenum Encodingβ encoding used in transfer. values:encodingBinary = 0,encodingChunkedenum Methodβ type of fetch. values:methodHttpGet,methodHttpPut,methodHttpPost,methodHttpPostMultipart,methodFtpGet,methodFtpPut,methodFileGet,methodFilePutenum Protocolβ http protocol version. values:protocolHttp1_0,protocolHttp1_1
π¦ Public Member Functions π¦
URLStream (Family family=IPV4, timeout_t timer=0)β construct an instance of URL stream.URLStream & getline (char *buffer, size_t len)β line parsing with conversion.Error get (const char *url, size_t buffer=512)β get URL data from a named stream of a known buffer size.Error get (size_t buffer=512)β get URL data from a named stream of a known buffer size.Error submit (const char *url, const char **vars, size_t buffer=512)β submit URL with vars passed as argument array.Error post (const char *url, const char **vars, size_t buffer=512)β post URL vars with post method.Error post (const char *url, MIMEMultipartForm &form, size_t buffer=512)β post URL with MIME multipart form.Error head (const char *url, size_t buffer=512)β used to fetch header information for a resource.void close ()β close the URL stream for a new connection.void setReferer (const char *str)β set the referer url.void setHost (const char *str)β set the host for the url.void setAddress (const char *str)β set the address for the url.void setCookie (const char *str)β set the cookie to pass.void setUser (const char *str)β set user id for the url.void setPassword (const char *str)β set password for the url.void setAuthentication (Authentication a, const char *str=NULL)β set authentication type for the url.void setProxyUser (const char *str)β set proxy user id for the url.void setProxyPassword (const char *str)β set proxy password for the url.void setProxyAuthentication (Authentication a, const char *str=NULL)β set proxy authentication type for the url.void setPragma (const char *str)β set the pragmas.void setProxy (const char *host, tpport_t port)β set the proxy server used.void setAgent (const char *str)β set the agent.Method getMethod (void)β get url method (and protocol) employed.void setTimeout (timeout_t to)β set socket timeout characteristics for processing URL requests.void setFollow (bool enable)β specify url following.void setProtocol (Protocol pro)β specify http protocol level being used.void setLocalInterface (const char *intf)β specify local interface to use.
π Protected Member Functions π
Error sendHTTPHeader (const char *url, const char **vars, size_t bufsize)β send http header to server.int underflow (void)β called if stream buffer needs refilling.virtual int aRead (char *buffer, size_t len, timeout_t timer)β derived method for async or timed I/O function on url stream.virtual int aWrite (char *buffer, size_t len, timeout_t timer)β derived method for async or timed I/O function on url stream.virtual void httpHeader (const char *header, const char *value)β derived method to receive and parse http 'headers'.virtual char ** extraHeader (void)β a virtual to insert additional header info into the request.
π Protected Attributes π
ost::String m_hostost::String m_address
β Related Functions β
(Note that these are not member functions.) β they're the free-floating besties, they don't live inside the class, they just hang around outside being helpful π§
__EXPORT char * urlDecode (char *source, char *dest=NULL)β decode an url parameter (ie'20'->' ')__EXPORT char * urlEncode (const char *source, char *dest, size_t size)β encode an url parameter (ie' '->'+')__EXPORT char * b64Decode (char *src, char *dest=NULL)β decode a string using base64 coding.__EXPORT char * b64Encode (const char *source, char *dest, size_t size)β encode a string using base64 coding.__EXPORT size_t b64Encode (const unsigned char *src, size_t srcsize, char *dst, size_t dstsize)β encode a octet stream using base64 coding.__EXPORT size_t b64Decode (const char *src, unsigned char *dst, size_t dstsize)β decode a string using base64 coding.__EXPORT String b64Encode (const String &src)β encode a STL string using base64 coding into a STL string.__EXPORT String b64Decode (const String &src)β decode a STL string using base64 coding into an STL String.__EXPORT String b64Encode (const unsigned char *src, size_t srcsize)β encode a octet stream using base64 coding into a STL string.__EXPORT size_t b64Decode (const String &src, unsigned char *dst, size_t dstsize)β decode a string using base64 coding.
π Additional Inherited Members π
(she's got inherited stuff too, iykyk β that's the TCPStream family baggage π
)
π Detailed Description π
A URL processing version of TCPStream. π
Author
David Sugar dyfet@ostel.com
C++ url processing stream class.
Examples
urlfetch.cpp, and xmlfetch.cpp.
π Member Enumeration Documentation π
enum ost::URLStream::Authentication
Type of authentication.
Enumerator
authAnonymousauthBasic
enum ost::URLStream::Encoding
Encoding used in transfer.
Enumerator
encodingBinaryencodingChunked
enum ost::URLStream::Error
Return error for url fetch.
Enumerator
errSuccesserrUnreachableerrMissingerrDeniederrInvaliderrForbiddenerrUnauthorizederrRelocatederrFailureerrTimeouterrInterface
enum ost::URLStream::Method
Type of fetch.
Enumerator
methodHttpGetmethodHttpPutmethodHttpPostmethodHttpPostMultipartmethodFtpGetmethodFtpPutmethodFileGetmethodFilePut
enum ost::URLStream::Protocol
http protocol version
Enumerator
protocolHttp1_0protocolHttp1_1
πΈ Constructor & Destructor Documentation πΈ
ost::URLStream::URLStream (Family family = IPV4, timeout_t timer = 0)
Construct an instance of URL stream. β¨
Parameters
- family β protocol to use.
- timer β for default timeout on I/O operations.
okay so that's the types and the constructors and the enum lore, and bestie we are not even close to done β the member function deep-dive is still coming, so don't you dare close the tab π₯
β¨ MEMBER FUNCTION DOCUMENTATION β¨
Okay bestie, this is the big one. All the member functions, in order, no skips. Let's get into it. π
virtual int ost::URLStream::aRead (char * buffer, size_t len, timeout_t timer) [protected], [virtual]
Derived method for async or timed I/O function on url stream. Yes queen, it's virtual and protected.
Returns: number of bytes read or < 0 for error.
Parameters:
bufferβ to read stream data into.lenβ of bytes to read from stream.timerβ to wait for data in milliseconds.
virtual int ost::URLStream::aWrite (char * buffer, size_t len, timeout_t timer) [protected], [virtual]
Derived method for async or timed I/O function on url stream. Writer energy.
Returns: number of bytes written or < 0 for error.
Parameters:
bufferβ to write stream data from.lenβ of bytes to write to stream.timerβ to wait for data in milliseconds.
void ost::URLStream::close ()
Close the URL stream for a new connection. Bye-bye, connection.
virtual char** ost::URLStream::extraHeader (void) [protected], [virtual]
A virtual to insert additional header info into the request.
Returns: array of header attributes to add.
Error ost::URLStream::get (const char * url, size_t buffer = 512)
Get URL data from a named stream of a known buffer size.
Returns: url error code.
Parameters:
urlβ name of resource.bufferβ size of buffer.
Error ost::URLStream::get (size_t buffer = 512)
Get URL data from a named stream of a known buffer size. Requesting URL defined in previous calls of setAddress() and setHost() functions.
Returns: url error code.
Parameters:
bufferβ size of buffer.
URLStream& ost::URLStream::getline (char * buffer, size_t len)
Line parsing with conversion.
Returns: URLStream object reference.
Parameters:
bufferβ to store.lenβ maximum buffer size.
Method ost::URLStream::getMethod (void) [inline]
Get url method (and protocol) employed.
Returns: url method in effect.
Error ost::URLStream::head (const char * url, size_t buffer = 512)
Used to fetch header information for a resource.
Returns: url error code.
Parameters:
urlβ name of resource.bufferβ size of buffer.
virtual void ost::URLStream::httpHeader (const char * header, const char * value) [protected], [virtual]
Derived method to receive and parse http 'headers'.
Parameters:
headerβ keyword.valueβ header keyword value.
Error ost::URLStream::post (const char * url, const char ** vars, size_t buffer = 512)
Post URL vars with post method.
Returns: success or error code.
Parameters:
urlβ name of resource being posted.varsβ to set in post.bufferβ size of buffer.
Error ost::URLStream::post (const char * url, MIMEMultipartForm & form, size_t buffer = 512)
Post URL with MIME multipart form.
Returns: success or error code.
Parameters:
urlβ name of resource being posted.formβ multi-part resource.bufferβ size to use.
Error ost::URLStream::sendHTTPHeader (const char * url, const char ** vars, size_t bufsize) [protected]
Send http header to server.
Parameters:
urlβ base to send header tovarsβ to post or use in get methodbufsizeβ of stream buffering to use
Returns: success or class error
void ost::URLStream::setAddress (const char * str) [inline]
Set the address for the url.
Parameters:
strβ address in the URL.
void ost::URLStream::setAgent (const char * str) [inline]
Set the agent.
Parameters:
strβ agent value.
void ost::URLStream::setAuthentication (Authentication a, const char * str = NULL)
Set authentication type for the url.
Parameters:
aβ authentication.strβ string.
void ost::URLStream::setCookie (const char * str) [inline]
Set the cookie to pass.
Parameters:
strβ cookie string.
void ost::URLStream::setFollow (bool enable) [inline]
Specify url following. Set to false to disable following of relocation requests.
Parameters:
enableβ true to enable following.
void ost::URLStream::setHost (const char * str) [inline]
Set the host for the url.
Parameters:
strβ host address.
void ost::URLStream::setLocalInterface (const char * intf) [inline]
Specify local interface to use.
Parameters:
intfβ Local interface name
void ost::URLStream::setPassword (const char * str) [inline]
Set password for the url.
Parameters:
strβ password.
void ost::URLStream::setPragma (const char * str) [inline]
Set the pragmas.
Parameters:
strβ pragma setting.
void ost::URLStream::setProtocol (Protocol pro) [inline]
Specify http protocol level being used.
Parameters:
proβ protocol level.
void ost::URLStream::setProxy (const char * host, tpport_t port)
Set the proxy server used.
Parameters:
hostβ proxy host.portβ proxy port.
void ost::URLStream::setProxyAuthentication (Authentication a, const char * str = NULL)
Set proxy authentication type for the url.
Parameters:
aβ authentication.strβ string.
void ost::URLStream::setProxyPassword (const char * str) [inline]
Set proxy password for the url.
Parameters:
strβ password.
void ost::URLStream::setProxyUser (const char * str) [inline]
Set proxy user id for the url.
Parameters:
strβ user id.
void ost::URLStream::setReferer (const char * str)
Set the referer url.
Parameters:
strβ referer string.
void ost::URLStream::setTimeout (timeout_t to) [inline]
Set socket timeout characteristics for processing URL requests. Set to 0 for no default timeouts.
Parameters:
toβ timeout to set.
void ost::URLStream::setUser (const char * str) [inline]
Set user id for the url.
Parameters:
strβ user id.
Error ost::URLStream::submit (const char * url, const char ** vars, size_t buffer = 512)
Submit URL with vars passed as argument array. This submit assumes 'GET' method. Use 'post' member to perform post.
Returns: url error code.
Parameters:
urlβ name of resource.varsβ to set.bufferβ size of buffer.
int ost::URLStream::underflow (void) [protected]
Called if stream buffer needs refilling.
Returns: number of bytes refilled or error if < 0
π« FRIENDS AND RELATED FUNCTION DOCUMENTATION π«
These are the related functions. So many base64 and url helpers, bestie.
__EXPORT char * b64Decode (char * src, char * dest = NULL) [related]
Decode a string using base64 coding. Destination size should be at least strlen(src)+1. Destination will be a string, so is always terminated . This function is deprecated, base64 can use binary source, not only string use overloaded b64Decode.
Returns: string coded
Parameters:
srcβ source bufferdestβ destination buffer. IfNULLsrc is used
__EXPORT size_t b64Decode (const char * src, unsigned char * dst, size_t dstsize) [related]
Decode a string using base64 coding. Destination size should be at least strlen(src)/4*3. Destination are not string terminated (It's just a octet stream).
Returns: number of octets written into destination buffer
Parameters:
srcβ source stringdstβ destination octet bufferdstsizeβ destination buffer size
__EXPORT String b64Decode (const String & src) [related]
Decode a STL string using base64 coding into an STL String. Destination size should be at least strlen(src)/4*3. Destination are not string terminated (It's just a octet stream).
Returns: decoded string
Parameters:
srcβ source string
__EXPORT size_t b64Decode (const String & src, unsigned char * dst, size_t dstsize) [related]
Decode a string using base64 coding. Destination size should be at least strlen(src)/4*3. Destination are not string terminated (It's just a octet stream).
Returns: number of octets written into destination buffer
Parameters:
srcβ source stringdstβ destination octet bufferdstsizeβ destination buffer size
__EXPORT char * b64Encode (const char * source, char * dest, size_t size) [related]
Encode a string using base64 coding. Destination size should be at least strlen(src)/4*3+1. Destination is string terminated. This function is deprecated, coded stream can contain terminator character use overloaded b64Encode instead.
Returns: destination buffer
Parameters:
sourceβ source stringdestβ destination octet buffersizeβ destination buffer size
__EXPORT String b64Encode (const String & src) [related]
Encode a STL string using base64 coding into a STL string.
Returns: base 64 encoded string
Parameters:
srcβ source string
__EXPORT String b64Encode (const unsigned char * src, size_t srcsize) [related]
Encode a octet stream using base64 coding into a STL string.
Returns: base 64 encoded string
Parameters:
srcβ source buffersrcsizeβ source buffer size
__EXPORT size_t b64Encode (const unsigned char * src, size_t srcsize, char * dst, size_t dstsize) [related]
Encode a octet stream using base64 coding. Destination size should be at least (srcsize+2)/3*4+1. Destination will be a string, so is always terminated (unless you pass dstsize == 0).
Returns: size of string written not counting terminator
Parameters:
srcβ source buffersrcsizeβ source buffer sizedstβ destination bufferdstsizeβ destination buffer size
__EXPORT char * urlDecode (char * source, char * dest = NULL) [related]
Decode an url parameter (ie '\%20' -> ' ')
Parameters:
sourceβ stringdestβ destination buffer. IfNULLsource is used
__EXPORT char * urlEncode (const char * source, char * dest, size_t size) [related]
Encode an url parameter (ie ' ' -> '+')
Parameters:
sourceβ stringdestβ destination buffer. Do not overlap with sourcesizeβ destination buffer size.
πΎ MEMBER DATA DOCUMENTATION πΎ
ost::String ost::URLStream::m_address[protected]ost::String ost::URLStream::m_host[protected]
That's it. Two protected String members. No cap.
π AUTHOR π
Generated automatically by Doxygen for GNU CommonC++ from the source code.
Okay bestie, that's the whole page! π This gem is from GNU CommonC++, dated Sun Dec 27 2020, and it's all about ost::URLStream(3). Go slay. π
β¨
π¦ where this page comes from
- ubuntu jammy: libcommoncpp2-doc 1.8.1-10
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms