Crow  0.3
A C++ microframework for the web
crow::response Struct Reference

HTTP response. More...

#include <http_response.h>

Classes

struct  static_file_info
 This constains metadata (coming from the stat command) related to any static files associated with this response. More...
 

Public Member Functions

void set_header (std::string key, std::string value)
 Set the value of an existing header in the response.
 
void add_header (std::string key, std::string value)
 Add a new header to the response.
 
const std::string & get_header_value (const std::string &key)
 
 response (int code)
 
 response (std::string body)
 
 response (int code, std::string body)
 
 response (returnable &&value)
 
 response (returnable &value)
 
 response (int code, returnable &value)
 
 response (response &&r)
 
 response (std::string contentType, std::string body)
 
 response (int code, std::string contentType, std::string body)
 
responseoperator= (const response &r)=delete
 
responseoperator= (response &&r) noexcept
 
bool is_completed () const noexcept
 Check if the response has completed (whether response.end() has been called)
 
void clear ()
 
void redirect (const std::string &location)
 
void redirect_perm (const std::string &location)
 
void moved (const std::string &location)
 
void moved_perm (const std::string &location)
 
void write (const std::string &body_part)
 
void end ()
 Set the response completion flag and call the handler (to send the response).
 
void end (const std::string &body_part)
 Same as end() except it adds a body part right before ending.
 
bool is_alive ()
 Check if the connection is still alive (usually by checking the socket status).
 
bool is_static_type ()
 Check whether the response has a static file defined.
 
void set_static_file_info (std::string path)
 Return a static file as the response body.
 
template<typename Adaptor >
void do_stream_file (Adaptor &adaptor)
 Stream a static file.
 
template<typename Adaptor >
void do_stream_body (Adaptor &adaptor)
 Stream the response body (send the body in chunks).
 

Public Attributes

int code {200}
 The Status code for the response.
 
std::string body
 The actual payload containing the response data.
 
ci_map headers
 HTTP headers.
 
bool is_head_response = false
 Whether this is a response to a HEAD request.
 
bool manual_length_header = false
 Whether Crow should automatically add a "Content-Length" header.
 

Friends

template<typename Adaptor , typename Handler , typename ... Middlewares>
class crow::Connection
 

Detailed Description

HTTP response.

Member Function Documentation

◆ moved()

void crow::response::moved ( const std::string &  location)
inline

Return a "Found (Moved Temporarily)" response.

Location can either be a route or a full URL.

◆ moved_perm()

void crow::response::moved_perm ( const std::string &  location)
inline

Return a "Moved Permanently" response.

Location can either be a route or a full URL.

◆ redirect()

void crow::response::redirect ( const std::string &  location)
inline

Return a "Temporary Redirect" response.

Location can either be a route or a full URL.

◆ redirect_perm()

void crow::response::redirect_perm ( const std::string &  location)
inline

Return a "Permanent Redirect" response.

Location can either be a route or a full URL.


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