/*
* Copyright (c) 2004 Aleksander B. Demko
*
* All rights reserved.
*
* This material is confidential and proprietary information of
* Aleksander B. Demko ("Confidential Information").
* This Confidential Information may only be used and reproduced
* in accordance with the terms of the license agreement.
*
*/
#ifndef __INCLUDED_WEXUS_CORE_RESPONSE_H__
#define __INCLUDED_WEXUS_CORE_RESPONSE_H__
#include <list>
#include <string>
#include <wexus/core/content.h>
namespace wexus
{
namespace core
{
class response;
}
}
/**
* A response object. This is what a handler returns back to the core
* server for eventual output to the client.
*
* @author Aleksander Demko
*/
class wexus::core::response
{
public:
typedef std::list<content_i*> content_list_t;
public:
/// default ctor
response(void);
/// dtor
~response();
/// gets the content list
content_list_t & content_list(void) { return m_content_list; }
/// gets the content list
const content_list_t & content_list(void) const { return m_content_list; }
/// adds a content to the end of the content list
void add_content(content_i *cont);
/// sets the HTTP status code
void set_status(int code);
/// gets the HTTP status code
int get_status(void) const { return m_status; }
/// sets the content type
void set_content_type(const std::string &type);
const std::string & content_type(void) const;
void set_cookie(const std::string &name, const std::string &value);
void set_cookie(const std::string &name, const std::string &value,
int days_to_expire);
void set_cookie(const std::string &name, const std::string &value,
int days_to_expire, const std::string &domain, const std::string &path);
void set_redirect(const std::string &url);
const std::string & redirect(void) const;
/// adds a custom header
void add_header(const std::string &name, const std::string &value);
/// gets the custom headers
const std::list< std::pair<std::string, std::string> > & headers(void) const;
/// gets the cookies
const std::list< std::pair<std::string, std::string> > & cookies(void) const;
/// sets the character encoding
void set_character_encoding(const std::string &enc);
/// gets the character encoding
const std::string & character_encoding(void) const;
/// does this response indicate a redirect?
bool is_redirect(void) const;
/// should this response be cached?
void set_cacheable(bool cancache);
/// can this response be cached?
bool cacheable(void) const;
private:
std::string m_content_type;
std::string m_redirect;
std::string m_character_encoding;
std::list< std::pair<std::string, std::string> > m_headers;
std::list< std::pair<std::string, std::string> > m_cookies;
content_list_t m_content_list;
int m_status;
bool m_cacheable;
};
#endif