wibble  1.1
Public Member Functions | Public Attributes | List of all members
wibble::net::mime::Reader Struct Reference

#include <mime.h>

Collaboration diagram for wibble::net::mime::Reader:
Collaboration graph
[legend]

Public Member Functions

 Reader ()
 
bool read_line (int sock, std::string &res)
 Read a line from the file descriptor. More...
 
bool read_headers (int sock, std::map< std::string, std::string > &headers)
 Read MIME headers. More...
 
bool read_until_boundary (int sock, const std::string &boundary, std::ostream &out, size_t max=0)
 Read until boundary is found, sending data to the given ostream. More...
 
bool discard_until_boundary (int sock, const std::string &boundary)
 Read until boundary is found, sending data to the given ostream. More...
 
bool readboundarytail (int sock)
 Skip until the end of the boundary line. More...
 

Public Attributes

wibble::ERegexp header_splitter
 

Constructor & Destructor Documentation

wibble::net::mime::Reader::Reader ( )

Member Function Documentation

bool wibble::net::mime::Reader::discard_until_boundary ( int  sock,
const std::string &  boundary 
)

Read until boundary is found, sending data to the given ostream.

Returns
true if another MIME part follows, false if it is the last part (boundary has trailing –)

References wibble::list::count(), and readboundarytail().

Referenced by wibble::net::http::Params::parse_multipart().

bool wibble::net::mime::Reader::read_headers ( int  sock,
std::map< std::string, std::string > &  headers 
)

Read MIME headers.

Returns
true if there still data to read and headers are terminated by an empty line, false if headers are terminated by EOF

References header_splitter, wibble::iterator(), wibble::Regexp::match(), read_line(), wibble::str::tolower(), and wibble::str::trim().

Referenced by wibble::net::http::Params::parse_multipart(), and wibble::net::http::Request::read_headers().

bool wibble::net::mime::Reader::read_line ( int  sock,
std::string &  res 
)

Read a line from the file descriptor.

The line is terminated by <CR><LF>. The line terminator is not included in the resulting string.

Returns
true if a line was read, false if EOF

Note that if EOF is returned, res can still be filled with a partial line. This may happen if the connection ends after some data has been sent but before <CR><LF> is sent.

References wibble::list::count().

Referenced by read_headers(), and wibble::net::http::Request::read_method().

bool wibble::net::mime::Reader::read_until_boundary ( int  sock,
const std::string &  boundary,
std::ostream &  out,
size_t  max = 0 
)

Read until boundary is found, sending data to the given ostream.

Parameters
maxMaximum number of bytes to read, or 0 for unilimited until boundary
Returns
true if another MIME part follows, false if it is the last part (boundary has trailing –)

References wibble::list::count(), and readboundarytail().

Referenced by wibble::net::http::Params::parse_multipart(), and wibble::net::http::FileParam::FileInfo::read().

bool wibble::net::mime::Reader::readboundarytail ( int  sock)

Skip until the end of the boundary line.

Returns
true if the boundary does not end with –, else false

References wibble::list::count().

Referenced by discard_until_boundary(), and read_until_boundary().

Member Data Documentation

wibble::ERegexp wibble::net::mime::Reader::header_splitter

Referenced by read_headers().


The documentation for this struct was generated from the following files: