forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApacheConnector.h
More file actions
88 lines (65 loc) · 2.71 KB
/
ApacheConnector.h
File metadata and controls
88 lines (65 loc) · 2.71 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
//
// ApacheConnector.h
//
// $Id: //poco/1.4/ApacheConnector/include/ApacheConnector.h#2 $
//
// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef ApacheConnector_ApacheConnector_INCLUDED
#define ApacheConnector_ApacheConnector_INCLUDED
#include <string>
struct request_rec;
class ApacheServerRequest;
class ApacheRequestRec
/// This class wraps an Apache request_rec.
{
public:
ApacheRequestRec(request_rec* _pRec);
/// Creates the ApacheRequestRec;
bool haveRequestBody();
/// Returns true if the request contains a body.
int readRequest(char* buffer, int length);
/// Read up to length bytes from request body into buffer.
/// Returns the number of bytes read, 0 if eof or -1 if an error occurred.
void writeResponse(const char* buffer, int length);
/// Writes the given characters as response to the given request_rec.
void addHeader(const std::string& key, const std::string& value);
/// Adds the given key / value pair to the outgoing headers of the
/// http response.
void setContentType(const std::string& mediaType);
/// Sets the response content type.
void redirect(const std::string& uri, int status);
/// Redirects the response to the given uri.
void sendErrorResponse(int status);
/// Sends an error response with the given HTTP status code.
int sendFile(const std::string& path, unsigned int fileSize, const std::string& mediaType);
/// Sends the file given by fileName as response.
void copyHeaders(ApacheServerRequest& request);
/// Copies the request uri and header fields from the Apache request
/// to the ApacheServerRequest.
private:
request_rec* _pRec;
};
class ApacheConnector
/// This class provides static methods wrapping the
/// Apache API.
{
public:
enum LogLevel
{
PRIO_FATAL = 1, /// A fatal error. The application will most likely terminate. This is the highest priority.
PRIO_CRITICAL, /// A critical error. The application might not be able to continue running successfully.
PRIO_ERROR, /// An error. An operation did not complete successfully, but the application as a whole is not affected.
PRIO_WARNING, /// A warning. An operation completed with an unexpected result.
PRIO_NOTICE, /// A notice, which is an information with just a higher priority.
PRIO_INFORMATION, /// An informational message, usually denoting the successful completion of an operation.
PRIO_DEBUG, /// A debugging message.
PRIO_TRACE /// A tracing message. This is the lowest priority.
};
static void log(const char* file, int line, int level, int status, const char* text);
/// Log the given message.
};
#endif // ApacheConnector_ApacheConnector_INCLUDED