LLVM: include/llvm/Debuginfod/HTTPServer.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16#ifndef LLVM_DEBUGINFOD_HTTPSERVER_H

17#define LLVM_DEBUGINFOD_HTTPSERVER_H

18

21

22#ifdef LLVM_ENABLE_HTTPLIB

23

24namespace httplib {

25class Request;

26class Response;

27class Server;

28}

29#endif

30

31namespace llvm {

32

36

38public:

39 static char ID;

42

43private:

44 std::string Msg;

45};

46

48 friend HTTPServer;

49

50#ifdef LLVM_ENABLE_HTTPLIB

51private:

53 httplib::Response &HTTPLibResponse);

54 httplib::Response &HTTPLibResponse;

55#endif

56

57public:

59

61

62

63

66};

67

73

75

76

77

78

79typedef std::function<StringRef(size_t , size_t )>

81

82

92

93

94

95bool streamFile(HTTPServerRequest &Request, StringRef FilePath);

96

97

98

100#ifdef LLVM_ENABLE_HTTPLIB

101 std::unique_ptrhttplib::Server Server;

102 unsigned Port = 0;

103#endif

104public:

107

108

110

111

112

113

115

116

117

118 Error bind(unsigned Port, const char *HostInterface = "0.0.0.0");

119

120

121

123

124

125

127

128

130};

131}

132

133#endif

Base class for user error types.

Lightweight error class with error context and mandatory checking.

Tagged union holding either a T or a Error.

HTTPServerError(const Twine &Msg)

void log(raw_ostream &OS) const override

Print an error message to an output stream.

static char ID

Definition HTTPServer.h:39

Definition HTTPServer.h:47

std::string UrlPath

Definition HTTPServer.h:58

void setResponse(StreamingHTTPResponse Response)

SmallVector< std::string, 1 > UrlPathMatches

The elements correspond to match groups in the url path matching regex.

Definition HTTPServer.h:60

An HTTP server which can listen on a single TCP/IP port for HTTP requests and delgate them to the app...

Definition HTTPServer.h:99

Error get(StringRef UrlPathPattern, HTTPRequestHandler Handler)

Registers a URL pattern routing rule.

Error bind(unsigned Port, const char *HostInterface="0.0.0.0")

Attempts to assign the requested port and interface, returning an Error upon failure.

Error listen()

Attempts to listen for requests on the bound port.

static bool isAvailable()

Returns true only if LLVM has been compiled with a working HTTPServer.

void stop()

If the server is listening, stop and unbind the socket.

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

This class implements an extremely fast bulk output stream that can only output to a stream.

This is an optimization pass for GlobalISel generic memory operations.

std::function< void(HTTPServerRequest &)> HTTPRequestHandler

Definition HTTPServer.h:74

@ Success

The lock was released successfully.

bool streamFile(HTTPServerRequest &Request, StringRef FilePath)

Sets the response to stream the file at FilePath, if available, and otherwise an HTTP 404 error respo...

std::function< StringRef(size_t, size_t)> HTTPContentProvider

An HTTPContentProvider is called by the HTTPServer to obtain chunks of the streaming response body.

Definition HTTPServer.h:80

Definition HTTPServer.h:68

const char * ContentType

Definition HTTPServer.h:70

StringRef Body

Definition HTTPServer.h:71

unsigned Code

Definition HTTPServer.h:69

Wraps the content provider with HTTP Status code and headers.

Definition HTTPServer.h:83

HTTPContentProvider Provider

Definition HTTPServer.h:87

unsigned Code

Definition HTTPServer.h:84

size_t ContentLength

Definition HTTPServer.h:86

const char * ContentType

Definition HTTPServer.h:85

std::function< void(bool)> CompletionHandler

Called after the response transfer is complete with the success value of the transfer.

Definition HTTPServer.h:90