/usr/include/ui-utilcpp/http/Connection.hpp is in libui-utilcpp-dev 1.8.3-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | /**
* @file
*/
#ifndef UI_UTIL_HTTP_CONNECTION_HPP
#define UI_UTIL_HTTP_CONNECTION_HPP
// STDC++
#include <iostream>
#include <string>
#include <vector>
// C++ Libraries
#include <ui-utilcpp/Socket.hpp>
#include <ui-utilcpp/http/Header.hpp>
namespace UI {
namespace Util {
namespace Http {
class Connection
{
private:
Socket * const socket_;
std::iostream * const stream_;
bool const externalStream_;
/** @brief Helper for constructors to destroy internal data on exception. */
void destroy();
public:
/** Connection w/ an existing stream. */
Connection(std::iostream & stream);
/** Connection w/ an open (socket) file descriptor. */
Connection(int fd, bool closeFd=false,
long int rcvToSeconds=0, long int rcvToMicroseconds=0,
long int sndToSeconds=0, long int sndToMicroseconds=0,
bool noBlock=false);
/** Connection w/ an INet peer. */
Connection(std::string const & host, unsigned int port,
long int rcvToSeconds=0, long int rcvToMicroseconds=0,
long int sndToSeconds=0, long int sndToMicroseconds=0,
bool noBlock=false);
#ifndef WIN32
/** Connection w/ an UNIX peer. */
Connection(std::string const & path,
long int rcvToSeconds=0, long int rcvToMicroseconds=0,
long int sndToSeconds=0, long int sndToMicroseconds=0,
bool noBlock=false);
#endif
~Connection();
/** @name Get socket information.
* @{ */
std::string getId() const;
std::string getPeerId() const;
std::string getConnId() const;
/** @} */
/** @name Get stream for arbitrary use.
* @{ */
std::iostream const & s() const;
std::iostream & s();
/** @} */
private:
std::streamsize readBlock(char * const buf, std::streamsize const & size, bool doThrow=true);
public:
/** @name Read utilities.
* @{ */
std::string readLine();
std::streamsize readBlock(std::string & block, std::streamsize const & size, bool doThrow=true);
std::string readBlock(std::streamsize const & size);
std::vector<char> readBlockVec(std::streamsize const & size);
Header & readHeader(Header & header);
Header readHeader();
/** @} */
/** @name Write utilities.
* @{ */
Connection & writeLine(std::string const & line="");
Connection & write(std::string const & block);
Connection & write(StatusLine const & statusLine);
Connection & write(RequestLine const & requestLine);
Connection & write(HeaderField const & oHeaderField, std::string const & prefix="");
Connection & write(Header const & header, std::string const & prefix="");
/** @} */
/** @name A simple "default" http request. */
std::string simpleHttpRequest(std::string const & body);
};
}}}
#endif
|