-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathlive.h
67 lines (45 loc) · 1.39 KB
/
live.h
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
/*
* Copyright (C) 2015-2018 Anton Burdinuk
* http://xupnpd.org
*/
#ifndef __LIVE_H
#define __LIVE_H
#include <string>
#include "http.h"
namespace live
{
struct handler_desc_t
{
std::string handler;
std::string opts;
handler_desc_t(const std::string& _handler,const std::string& _opts):handler(_handler),opts(_opts) {}
};
class req
{
protected:
http::req* client;
const char* mime;
std::map<std::string,std::string>* extras;
int st;
enum { max_headers_len=512 };
std::string headers;
int __get_extra_headers(std::string& dst);
bool __send_headers(socket_t sock,bool is_extra);
bool __real_send(socket_t sock,const char* buf,int len);
bool __send(socket_t sock,const char* buf,int len);
public:
bool is_headers_sent;
req(http::req* _client,const char* _mime,std::map<std::string,std::string>* _extras):client(_client),mime(_mime),extras(_extras),
st(0),is_headers_sent(false) {}
#ifndef _WIN32
bool __forward(socket_t src,socket_t dst);
#else
bool __forward(void* src,socket_t dst);
#endif /* _WIN32 */
};
bool init(void);
bool sendurl(http::req* req,const std::string& url,const std::string& handler,const char* mime,std::map<std::string,std::string>& extras);
void done(void);
}
#endif