/*!
 * Copyright (c) 2015-2018, NADAL Jean-Baptiste. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301 USA
 *
 * @Author:  NADAL Jean-Baptiste
 * @Date: 30/06/2017
 */

#ifndef _HTTP_HEADER_H
#define _HTTP_HEADER_H

/*------------------------------- INCLUDES ----------------------------------*/

#include <string>

/*----------------------------- Dependencies --------------------------------*/

struct client;
struct uhttpd_ops;

/*--------------------------------- CLASS ----------------------------------*/

class HttpHeader
{
  public:
	HttpHeader(void);
	HttpHeader(uint16_t a_timeout);

	void send(uhttpd_ops *an_ops, client *a_client, uint16_t a_code, bool a_chunked = false);
	void send_option(uhttpd_ops *an_ops, client *a_client, uint16_t a_code);

	void add_origin(const std::string &an_origin);
	void add_etag(const std::string &an_etag);
	void add_timeout(uint16_t a_timeout);

  private:
	bool use_chunked(struct client *a_client);
	void prepare_header(struct client *a_client, int a_code, const std::string &a_summary);

  private:
	std::string m_etag;
	std::string m_origin;
	uint16_t m_timeout;
};

#endif /* _HTTP_HEADER_H */
