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
|
/* Copyright (c) MediaArea.net SARL. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license that can
* be found in the License.html file in the root of the source tree.
*/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// LibEventHttpd functions
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//---------------------------------------------------------------------------
#ifdef HAVE_LIBEVENT
//---------------------------------------------------------------------------
#ifndef LibEventHttpdH
#define LibEventHttpdH
#include "Httpd.h"
#include <string>
#include <event2/event.h>
#include <event2/http.h>
#include <event2/buffer.h>
//---------------------------------------------------------------------------
namespace MediaConch
{
class MediaConchLib;
//***************************************************************************
// Class LibEventHttpd
//***************************************************************************
class LibEventHttpd : public Httpd
{
public:
//Constructor/Destructor
LibEventHttpd(void* arg);
virtual ~LibEventHttpd();
int init(std::string& err);
int bind(std::string& err);
int start(std::string& err);
int finish();
virtual int send_result(int ret_code, const std::string& ret_msg, void *arg);
private:
struct event_base *base;
struct evhttp *http;
struct evhttp_bound_socket *handle;
static int pid;
static void request_coming(struct evhttp_request *req, void *arg);
int get_body(struct evhttp_request *req, std::string& json, std::string& ret_msg);
void request_get_coming(struct evhttp_request *req, std::string& err);
void request_post_coming(struct evhttp_request *req, std::string& err);
void request_put_coming(struct evhttp_request *req, std::string& err);
void request_delete_coming(struct evhttp_request *req, std::string& err);
int uri_api_version_is_valid(std::string& uri, struct evhttp_request *req);
int get_mediaconch_instance(const struct evkeyvalq *headers);
LibEventHttpd (const LibEventHttpd&);
LibEventHttpd& operator=(const LibEventHttpd&);
};
}
#endif // !HAVE_LIBEVENT
#endif // !LibEventHttpdH
|