summaryrefslogtreecommitdiff
path: root/includes/Http.h
blob: 58edd23a0558228b64fea97f164c4e7ca8a16c9d (plain)
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
#pragma once

#include <map>
#include <BString.h>
#include <Handle.h>

#ifdef _MSC_VER
// SERIOUSLY ?!
#undef DELETE
#undef ERROR
#endif

namespace Balau {

namespace Http {

const char * getStatusMsg(int httpStatus);
const char * getContentType(const String & extension);
String percentEncode(const String & src);
String percentDecode(const String & src);

typedef std::map<String, String> StringMap;
typedef std::multimap<String, String> StringMultiMap;
typedef std::map<String, IO<Handle> > FileList;

struct Request {
    int method;
    String host;
    String uri;
    StringMap variables;
    StringMap cookies;
    StringMap headers; // this needs to become a StringMultiMap
    FileList files;
    bool persistent;
    bool upgrade;
    String version;
};

enum {
    GET,
    HEAD,
    POST,
    PUT,
    DELETE,
    TRACE,
    OPTIONS,
    CONNECT,
    BREW,
    PROPFIND,
    WHEN,

    REDIRECT = 301,

    BAD_REQUEST = 400,
    UNAUTHORIZED = 401,
    FORBIDDEN = 403,
    NOT_FOUND = 404,

    ERROR = 500,
};

};

};