wibble::net::mime::Reader Struct Reference

`#include <mime.h>`

Collaboration diagram for wibble::net::mime::Reader:
[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

## Reader()

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

## Member Function Documentation

## discard_until_boundary()

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().

## read_headers()

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().

## read_line()

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().

## read_until_boundary()

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

  max | Maximum 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().

## readboundarytail()

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

## header_splitter

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

Referenced by read_headers().

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

- mime.h
- mime.cpp